You are not logged in.

#1 2017-01-28 13:32:22

Kino
Member
From: Stockport, UK
Registered: 2016-04-30
Posts: 109

Conky: reading exec value failed

Here is the conky in question:

It displays the status of transmission downloads, etc.

#!/bin/sh
#conkytrans.sh

#transmission info in conky
host=127.0.0.1         #host:port

SERVICE='transmission'
 
if ps ax | grep -v grep | grep $SERVICE > /dev/null
then
    echo "$SERVICE service running, everything is fine"
for number in `transmission-remote -l | awk '{print $1}' | sed '1d;$d'`
do
torrentinfo=`transmission-remote "$host" -t $number -i`
name=`echo "$torrentinfo" | grep Name: | sed -e 's/\s\sName:\s//'`
percent=`echo "$torrentinfo"  | grep Percent | ssed -R 's/\ \ Percent\ Done:\ (\d+.\d+%)/\1/'`
percentbar=`echo $percent | ssed -R 's/(\d+).\d+%/\1/'`
if [ "$percentbar" -lt "10" ];then
  percentbar=`echo $percentbar | ssed -R 's/(\d)/0\1/'`
fi
total=`echo "$torrentinfo" | grep Total | ssed -R 's/\ \ Total\ size:\ (\d+.\d+\ \w{2}).*/\1/'`
download=`echo "$torrentinfo" | grep "Download Speed" | sed 's/\ \ Download\ Speed:\ //'`
eta=`echo "$torrentinfo" | grep ETA | sed 's/\ \ ETA:\ //'`

echo "$name"
echo "$percent of $total"
echo '${execbar echo '$percentbar'}'
echo "$download" "$eta"
echo "------------------------------"
done
else
    echo "$SERVICE is not running"
fi

I'll check it out in the terminal when I have transmission running.

Offline

#2 2017-01-28 14:25:27

Sector11
Mod Squid Tpyo Knig
From: Upstairs
Registered: 2015-08-20
Posts: 8,030

Re: Conky: reading exec value failed

Not a conky - a bash script that conky calls BUT there's your problem:

echo '${execbar echo '$percentbar'}'

try this:

${execbar echo '$percent'}

execbar     command     Same as exec, except if the first value return is a value between 0-100, it will use that number for a bar. The size for bars can be controlled via the default_bar_size config setting.

execbar creates the bar - all you need is the number and I'm guessing the '$percent' is coming from transmission.

I don't have transmission running so can't test.


Debian 12 Beardog, SoxDog and still a Conky 1.9er

Offline

#3 2017-01-28 14:40:17

damo
....moderator....
Registered: 2015-08-20
Posts: 6,734

Re: Conky: reading exec value failed

^ But "$percentbar" is a bash variable in this case, which I guess is an actual number.

@OP
I seriously advise that you run that script through shellcheck (you can install it or do it online). The script is riddled with unquoted variables and deprecated syntax, which could produce unexpected behaviour which could be very difficult to track down  sad


Be Excellent to Each Other...
The Bunsenlabs Lithium Desktop » Here
FORUM RULES and posting guidelines «» Help page for forum post formatting
Artwork on DeviantArt  «» BunsenLabs on DeviantArt

Offline

#4 2017-01-28 15:00:58

Kino
Member
From: Stockport, UK
Registered: 2016-04-30
Posts: 109

Re: Conky: reading exec value failed

OK, I tried shellcheck:

Your Terminal
$ shellcheck myscript
 
Line 9:
if ps ax | grep -v grep | grep $SERVICE > /dev/null
   ^-- SC2009: Consider using pgrep instead of grepping ps output.
 
Line 12:
for number in `transmission-remote -l | awk '{print $1}' | sed '1d;$d'`
              ^-- SC2006: Use $(..) instead of legacy `..`.
 
Line 14:
torrentinfo=`transmission-remote "$host" -t $number -i`
            ^-- SC2006: Use $(..) instead of legacy `..`.
                                            ^-- SC2086: Double quote to prevent globbing and word splitting.
 
Line 15:
name=`echo "$torrentinfo" | grep Name: | sed -e 's/\s\sName:\s//'`
     ^-- SC2006: Use $(..) instead of legacy `..`.
 
Line 16:
percent=`echo "$torrentinfo"  | grep Percent | ssed -R 's/\ \ Percent\ Done:\ (\d+.\d+%)/\1/'`
        ^-- SC2006: Use $(..) instead of legacy `..`.
 
Line 17:
percentbar=`echo $percent | ssed -R 's/(\d+).\d+%/\1/'`
           ^-- SC2006: Use $(..) instead of legacy `..`.
                 ^-- SC2086: Double quote to prevent globbing and word splitting.
 
Line 19:
  percentbar=`echo $percentbar | ssed -R 's/(\d)/0\1/'`
             ^-- SC2006: Use $(..) instead of legacy `..`.
                   ^-- SC2086: Double quote to prevent globbing and word splitting.
 
Line 21:
total=`echo "$torrentinfo" | grep Total | ssed -R 's/\ \ Total\ size:\ (\d+.\d+\ \w{2}).*/\1/'`
      ^-- SC2006: Use $(..) instead of legacy `..`.
 
Line 22:
download=`echo "$torrentinfo" | grep "Download Speed" | sed 's/\ \ Download\ Speed:\ //'`
         ^-- SC2006: Use $(..) instead of legacy `..`.
 
Line 23:
eta=`echo "$torrentinfo" | grep ETA | sed 's/\ \ ETA:\ //'`
    ^-- SC2006: Use $(..) instead of legacy `..`.
 
Line 27:
${execbar echo '$percentbar'}
^-- SC2154: execbar is referenced but not assigned.
               ^-- SC2016: Expressions don't expand in single quotes, use double quotes for that.

$ 

but, I'm afraid I don't understand much of it!
Any help would be appreciated.

Offline

#5 2017-01-28 15:12:09

damo
....moderator....
Registered: 2015-08-20
Posts: 6,734

Re: Conky: reading exec value failed

I think it is the last error that is the problem

Line 27:
${execbar echo '$percentbar'}
^-- SC2154: execbar is referenced but not assigned.
               ^-- SC2016: Expressions don't expand in single quotes, use double quotes for that.

Try

echo "\${execbar echo $percentbar}"
Kino wrote:

...but, I'm afraid I don't understand much of it!

Welcome to the wonderful world of bash scripting big_smile (Loads of tutorials online BTW)

-----
See the difference here: you want to output a literal "${....}", so you need to escape the "$". Try it in a terminal

damo@graphix ~ $ percentbar=100

damo@graphix ~ $ echo "${execbar echo $percentbar}"
bash: ${execbar echo $percentbar}: bad substitution

damo@graphix ~ $ echo "\${execbar echo $percentbar}"
${execbar echo 100}

Last edited by damo (2017-01-28 15:16:34)


Be Excellent to Each Other...
The Bunsenlabs Lithium Desktop » Here
FORUM RULES and posting guidelines «» Help page for forum post formatting
Artwork on DeviantArt  «» BunsenLabs on DeviantArt

Offline

#6 2017-01-28 15:35:22

Kino
Member
From: Stockport, UK
Registered: 2016-04-30
Posts: 109

Re: Conky: reading exec value failed

Welcome to the wonderful world of bash scripting big_smile (Loads of tutorials online BTW)

Yeah, I know!
Problem is, I don't use scripts enough to sit down and learn thoroughly.
It's a bit like having to learn Chinese when all you want is some noodles!

Thanks for help!

Offline

#7 2017-01-28 16:50:36

Sector11
Mod Squid Tpyo Knig
From: Upstairs
Registered: 2015-08-20
Posts: 8,030

Re: Conky: reading exec value failed

damo wrote:

^ But "$percentbar" is a bash variable in this case, which I guess is an actual number.

OOPS!  I have conky-brain can't see past conky variables.

Pass the noodles HoaS.  big_smile


Debian 12 Beardog, SoxDog and still a Conky 1.9er

Offline

#8 2017-01-28 18:08:26

Kino
Member
From: Stockport, UK
Registered: 2016-04-30
Posts: 109

Re: Conky: reading exec value failed

Ok

Have just used transmission, the modified bash script works fine and no errors given in xsession-errors.

Offline

Board footer

Powered by FluxBB