It is currently Sun May 20, 2018 7:22 pm

My VLC script won't read files from a smb share.

All times are UTC - 6 hours

Post new topic Reply to topic  [ 7 posts ] 
Author Message
 PostPosted: Tue Mar 30, 2010 10:10 pm   

Joined: Sat May 30, 2009 5:56 am
Posts: 15
I have this vlc script for automating VLC so that it plays a certain number of TV show episodes. Once you plug in the relevant path and create a list name for a text file where the absolute paths of all the media files get written, it plays a chosen number of files and then exits.

I've recently added a desktop to my PC lineup and now all my files are stored there. It's a Win7 box, and all the relevant directories are being shared. When the files were local, I had no problems at all. Now, I'm having a problem either with Samba, or with my file name structure which contains spaces and special characters. I'm not sure which is the cause of the problem.

On my Linux laptop, where this script is running, the shared folders are all permanently mounted in a mountpoint I created - /mnt/Shares/SubFolders

From the Linux laptop, I have full read/write access. I can execute the pertinent commands in this script manually from a terminal, and they complete successfully without any problems. When I try to run the script, though, it does create the list with the given name, but the file is empty, as though the folders were empty.

Here is the script:
# Creates a list of all files in all Simpsons folders and then
# plays so many random episodes with VLC Media Player.
# Created by Uncertain

# Filenames and paths.
# Check for the list. If it exists, fine.
# If it doesn't exist, create it.
if [ -f "$list" ]
  echo "List found."
    echo "Episodes list not found. Creating list arranged by season & episode..." && find "$path1" -name '*.avi' -o -name '*.mpg' -o -name '*.mp4' -o -type f -size +20M | sort > "$list" && cd ~ && echo "Done. List created"
# Set the number of episodes to play. Episodes are
# roughly 20 mins, so three episodes to every hour.
while  [ $cycles -ne $repeat ]
  echo $cycles
  cycles=$(( $cycles + 1 ))
# Read the list, select one random line.
Rand=`dd if=/dev/urandom count=1 2> /dev/null | cksum | cut -f1 -d" "`
UpperBound=`cat $list | wc -l`
let "Range = $UpperBound - $LowerBound + 1"
let "RandomLine = $LowerBound + ($Rand % $Range)"
episode=`sed -n "$RandomLine{p;q;}" "$list"`
# open the random line in VLC
vlc -vvv --fullscreen "$episode" vlc://quit
# Close the episode count loop...
# ...and then...

I assume it's a problem with the find|sort string, since it's creating an empty file list. I'm not sure what the problem would be, since I can copy & paste that command string into a terminal and it will execute without a problem. In fact, I can create the list manually like that, and the script will run without issue. When there's an empty list, though, VLC just opens & closes right away since there's no file being played.

Can anyone find the flaw?

 PostPosted: Wed Apr 14, 2010 5:54 pm   

Joined: Sat May 30, 2009 5:56 am
Posts: 15
Two solid weeks, and no replies, eh?

I guess this is a bump.

 PostPosted: Tue Apr 20, 2010 10:18 pm   

Joined: Sat May 30, 2009 5:56 am
Posts: 15
Three week bump.

Nobody can tell me why a command to find files in a given remote directory will execute when pasted into a terminal, but not when part of a script?

 PostPosted: Wed Apr 21, 2010 12:52 am   

Joined: Mon Mar 02, 2009 3:03 am
Posts: 643
you shouldn't chain your find from echo
echo && find does not make much sense

 PostPosted: Wed Apr 21, 2010 2:04 pm   

Joined: Sat May 30, 2009 5:56 am
Posts: 15
But it works. Look at the conditions: if -f $list echo "list found", else echo "not found" and build the list with the find string. Which part doesn't make sense?

Truthfully, none of the echoes need to even be there. It's the first script I ever wrote, I built it a section at a time, and needed those messages in the terminal to know which stage it was in as I strung it all together.

When all's said and done, that has nothing to do with why the command won't find folders inside a samba share when it's part of a script, but works fine when copied & pasted to the command line.

 PostPosted: Tue Apr 27, 2010 12:44 am   
User avatar

Joined: Sat Jun 13, 2009 8:53 pm
Posts: 73
Location: Texas!
I'm not sure what's wrong with the find | sort bit. I would try systematically removing things from that command until you get something that works, and then build it back up from there. For example, start by removing the "sort" and output directly to file. Then, remove some of the expressions from find. Last, run the find command on a normal directory. Somewhere in there, you should be able to find out what's not working.

- thobbs

 PostPosted: Tue Apr 27, 2010 8:21 pm   

Joined: Sat May 30, 2009 5:56 am
Posts: 15
Thanks for the reply, thobbs. I actually more or less did that - it's what led me to find that I could execute the command manually from a command prompt and have it execute normally. Since the folders in question are on an external USB drive, I've been able to try with the drive connected directly to the computer this command (script) is running on, and it works flawlessly when the files are local.

I thought it might be the mountpoints I had set for the top-level dir that holds the folder I'm indexing, but I've changed the from places in /home/name/XXXX, to /media/XXXX, to where they currently are inside /mnt/XXXX.

I'll give it another go, though, and see what I come up with.

Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC - 6 hours

Who is online

Users browsing this forum: No registered users and 7 guests

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  

BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group