Register
It is currently Sun Nov 23, 2014 11:04 am

Script works, but with errors, need help!


All times are UTC - 6 hours


Post new topic Reply to topic  [ 3 posts ] 
Author Message
 PostPosted: Tue Mar 06, 2012 9:19 am   

Joined: Tue Mar 06, 2012 9:03 am
Posts: 2
I've written a conky script for use with deadbeef music player, but when run i get this error in the terminal: /home/jeremy/.scripts/dbconky.sh: line 11: [: too many arguments

the script is:

Code:
#!/bin/bash
INPUT=$1

case $INPUT in
  AR)
   if [ -z "$(pidof deadbeef)" ]
    then
      echo "--"
   else
ARTIST=`deadbeef --nowplaying %a`
   if [ $ARTIST = "nothing" ]
    then
      echo "STOPPED"
   else
      echo "$ARTIST"
fi
fi
  ;;
  EL)
   if [ -z "$(pidof deadbeef)" ]
    then
      echo "--"
   else
ELAPSE=`deadbeef --nowplaying %e`
   if [ $ELAPSE = "nothing" ]
    then
      echo "--"
   else
      echo "$ELAPSE"
fi
fi
  ;;
  LN)
   if [ -z "$(pidof deadbeef)" ]
    then
      echo "--"
   else
LENGTH=`deadbeef --nowplaying %l`
   if [ $LENGTH = "nothing" ]
    then
      echo "--"
   else
      echo "$LENGTH"
fi
fi
  ;;
  TT)
   if [ -z "$(pidof deadbeef)" ]
    then
      echo "--"
   else
TITLE=`deadbeef --nowplaying %t`
   if [ $TITLE = "nothing" ]
    then
      echo "STOPPED"
   else
      echo "$TITLE"
fi
fi
  ;;
esac


Top
 Profile  
 PostPosted: Tue Mar 06, 2012 11:05 pm   

Joined: Mon Mar 02, 2009 3:03 am
Posts: 567
hi,

use more quotes
Code:
if [ "$artitst" = "nothing" ]


don't use uppercase variable names, that's for environmental variables.
take care of indentation.

does deadbeef really output 'nothing'?


Top
 Profile  
 PostPosted: Wed Mar 07, 2012 3:22 am   

Joined: Tue Mar 06, 2012 9:03 am
Posts: 2
thanks alot! that fixed it! and yes, if deadbeef is not actually playing music, querying it gives 'nothing' as a response for everything (time elapsed, total length, artist, etc. everything)


Top
 Profile  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot] 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
© 2003 - 2011 USA LINUX USERS GROUP