Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I'm writing a couple of scripts to start vlc and periodically update its playlist. The update_pls.sh works well if I execute it from prompt, but when I call it from start_vlc.sh, in each for cycle I get this:

./update_pls.sh: 20: ./update_pls.sh: 10#18: not found
./update_pls.sh: 20: ./update_pls.sh: 10#18==DIA: not found

start_vlc.sh:

   #!/bin/bash
   echo `date`
   echo "A arrancar o VLC..."
   cvlc --loop --fullscreen --extraintfttp --http-password kepler
   sh update_pls.sh

update_pls.sh:

   #!/bin/bash
   /usr/bin/env > /Videos/cron_env.log
   DIR=/Videos
   FILES=$DIR/*
   DIA=`(date +%d)`
   HORA=`(date +%H)`
   echo `date`
   echo "Dir: $DIR"
   echo "A fazer update da playlist.m3u..."
   > $DIR/playlist.m3u
   for f in $FILES
   do
     a=`(basename $f .mov | cut -b 1-2 | sed 's/[^0-9]//g')`
     b=`(basename $f .mov | cut -b 3-4 | sed 's/[^0-9]//g')`
     if [ -n "$a" ]; then    
       :
     else
       a="99"
     fi
     if (( 10#$a<DIA)) || ((10#$a==DIA && 10#$b<=HORA )); then
       echo -e "$f\n" >> $DIR/playlist.m3u
       echo "Adicionado o video $f"
     fi
   done
   echo "A fazer upload da playlist para o VLC..."
   curl -u '':kepler "http://localhost:8080/requests/status.xml?command=pl_empty"
   curl -u '':kepler "http://localhost:8080/requests/status.xml?command=in_enqueue&input$
   curl -u '':kepler "http://localhost:8080/requests/status.xml?command=pl_play"

I can't manage to find the cause of this and would apreciate any help. Vasco

share|improve this question
    
When you are calling the script, can you put in the directory the script is located in? For example .~/directory/scriptName.sh –  ryekayo Aug 21 at 18:05
    
both scripts, and files it's supposed to add to the playlist, are in the same folder, p.e. /home/vasco/videos/. –  Vasco Sotomaior Aug 21 at 18:08
    
Ok next dumb question lol: is the script listed as an executable? –  ryekayo Aug 21 at 18:09
1  
@VascoSotomaior in UNIX world, you have to specify path for executing script or run from $PATH. –  Mohsen Pahlevanzadeh Aug 21 at 18:11
    
yup, after writing them i ran sudo chmod +x *.sh –  Vasco Sotomaior Aug 21 at 18:11

1 Answer 1

Your update_pls.sh is a bash script, but when you invoke it from start_vlc.sh you use sh which probably doesn't run bash on your system. Try either changing the line to bash update_pls.sh or do chmod a+x on update_pls.sh and just invoke it directly as a command.

A few notes on your scripts:

In the line echo `date`, echo is unnecessary, just use date.

No need for parenthesis in lines like DIA=`(date +%d)`, including these will start another instance of your shell and add a lot of overhead to the script. DIA=$(date) is probably the most preferable form (here the dollar brackets replace the backticks), see Have backticks (i.e. `cmd`) in *sh shells been deprecated?.

No need for a : in your if/else, just do if ! [ -n "$a" ]; then and you can drop the else part.

There are some other things, but I think that is enough from me.

share|improve this answer
2  
@mikeserv On my Debian system /bin/sh is a symlink to dash. –  Dubu Aug 21 at 22:23
    
@Dubu - thats true. Id forgotten that. dash is a better shell than bash's --posix mode anyway, as it too often confuses itself, i think. And it will be that way on all Debian based systems - which completely invalidates my comment. Sorry, Graeme. In all, though, i would recommend vlc -I lua - which invokes vlc's own scriptable cli - over all of this. –  mikeserv Aug 21 at 22:25

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.