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


   echo `date`
   echo "A arrancar o VLC..."
   cvlc --loop --fullscreen --extraintfttp --http-password kepler
   sh update_pls.sh


   /usr/bin/env > /Videos/cron_env.log
   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
     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    
     if (( 10#$a<DIA)) || ((10#$a==DIA && 10#$b<=HORA )); then
       echo -e "$f\n" >> $DIR/playlist.m3u
       echo "Adicionado o video $f"
   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

  • 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 '14 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/. Aug 21 '14 at 18:08
  • Ok next dumb question lol: is the script listed as an executable?
    – ryekayo
    Aug 21 '14 at 18:09
  • 1
    @VascoSotomaior in UNIX world, you have to specify path for executing script or run from $PATH. Aug 21 '14 at 18:11
  • yup, after writing them i ran sudo chmod +x *.sh Aug 21 '14 at 18:11

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.

  • 2
    @mikeserv On my Debian system /bin/sh is a symlink to dash.
    – Dubu
    Aug 21 '14 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 '14 at 22:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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