shell script for conky getting errors....

So I have a script that does a greater than or less than with a variable. My problem is that when I checked the script from the command line I was getting this error..

I am not really familiar with shell scripting. I am trying to get this script to work with conky so that it will do the functions and give the output. I got this script online, so it might be done all wrong...

./wlanscript.sh: line 23: [: : integer expression expected
./wlanscript.sh: line 4: [: : integer expression expected
./wlanscript.sh: line 4: [: : integer expression expected
./wlanscript.sh: line 6: [: : integer expression expected
./wlanscript.sh: line 8: [: : integer expression expected
./wlanscript.sh: line 10: [: : integer expression expected
#! /bin/bash
function dload()
{
    if [ "$lq" -lt 100 ] || [ "$lq" -gt 65 ]; then
        echo '${image /home/kris/.images/wlan100.png -s 94x79 -p 10,25}'
    elif [ "$lq" -lt 66 ] && [ "$lq" -gt 55 ]; then
        echo '${image /home/kris/.images/wlan50.png -s 94x79 -p 10,25}'
    elif [ "$lq" -lt 56 ] && [ "$lq" -gt 49 ]; then
        echo '${image /home/kris/.images/wlan40.png -s 94x79 -p 10,25}'
    elif [ "$lq" -lt 50 ] && [ "$lq" -gt 5 ]; then
        echo '${image /home/kris/.images/wlan5.png -s 94x79 -p 10,25}'
    fi


}
function usage()
{
echo '${image /home/kris/.images/wlan0.png -s 94x79 -p 10,25}'
}

lq=$(iwconfig wlan0|grep 'Link Quality:'|grep :|grep --max-count=1 -o '\:\([0-9]\+\)'|grep --max-count=1 -o '\([0-9]\+\)')

if [ "$lq" -lt 5 ]
then
    usage
else
    dload
fi

For a test. Just after setting the value of $lq , try displaying the value:

echo "lq = $lq"

Assuming that the value is definitely an integer number, then lose the double quotes in all your integer comparisons.

I dont want to sound stupid with this question, but where do you want me to set it in the code that I posted?

I assume you want the Signal Level?

My iwconfig has values separated by "=".

root@bt > iwconfig wlan0|grep 'Link Quality=' 
          Link Quality=56/70  Signal level=-54 dBm  

So, the following statement gives me the Signal Strength

iwconfig wlan0|grep 'Link Quality=' | grep --max-count=1 -o '\=\([0-9]\+\)' | grep --max-count=1 -o '\([0-9]\+\)'
60

If the above does not work, paste the output of iwconfig wlan0

Try this also...
For Signal Level

root@bt > iwconfig wlan0 | sed -n 's/.*Signal level[:=]-\([0-9]*\).*/\1/gp'
56

Usage in your script would be

lp=$( iwconfig wlan0 | sed -n 's/.*Signal level[:=]-\([0-9]*\).*/\1/gp' )

--ahamed

So this was the output:

iwconfig eth1 | sed -n 's/.*Signal level[:=]-\([0-9]*\).*/\1/gp'
gave me nothing back
M1330:~$ sudo iwconfig eth1 | sed -n 's/.*Signal level[:=]-\([0-9]*\).*/\1/gp'
46 Gave me a signal back

It only works when I use sudo. And my wireless uses eth1. I need to find a way to get past the sudo iwconfig eth1 thing.....any ideas? As long as I use sudo I can get a signal # back. If I don't use sudo, then nothing... The only way that I was able to get the bitrate and ssid is by doing sudo conky. If I do just conky, then those two things won't show up. It's like their hidden behind root priveleges for some reason...

Yes, iwconfig/ifconfig etc are admin commands. Looks like sudo is configured for the user you are trying with. So there shouldn't be a problem.

--ahamed

So how could I get rid of the sudo way with the conky scripts?

I am not very familiar with conky. I just installed and tried invoking with a normal user and it required root privileges.

My question is : If sudo is configured for you, why don't you want to use it?

If prefixing sudo is a problem for you, try creating an alias kind in your script and use that... Something like this...

CONKY="/usr/bin/sudo /usr/bin/conky"
...
...
$CONKY inputargs

--ahamed

My main problem now is that I still cant get the wlanscript.sh to work with my conky. I feel like I have all the paths right, but I cannot get the picture for the signal to show up at all...Here is the code:

override_utf8_locale yes
use_xft yes
xftfont verdana:size=8
alignment top_left
xftalpha 0.8
own_window class Conky
own_window yes
#own_window_type override
own_window_type conky
own_window_transparent yes
own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager
double_buffer yes
draw_shades no
draw_outline no
draw_borders no
stippled_borders 10
border_margin 4
border_width 1
default_shade_color grey
default_outline_color black
default_color BADCDD
use_spacer none
no_buffers yes
uppercase no
color1 4D6844
color0 E6E6E6
color1 A7CC5C
color2 E6E6E6

minimum_size 310 310
maximum_width 310
    
#alignment tl
gap_x -20
gap_y 40



TEXT
#######################################
###             Logo              #####
#######################################
#${color D3DADF}${font OpenLogos:size=40}   S 
#######################################
###         HTC Weather            ####
#######################################  
${voffset 30}${font Helvetica LT Std :style=Condensed:size=60}${color 434343}${goto 42}${time %H}${goto 142}${color 434343}${time %M}${font Helvetica LT Std :size=15:style=condensed}${color 808080}${goto 229}${time %S}
${voffset 55}${color whitesmoke}${font Helvetica LT Std :size=8}${alignr 105}${time %A},${time %e},${time %B},${time %G}
${voffset -45}${goto 22}${font Helvetica LT Std :size=8}${color 909090}${execi 600 conkyForecast -i --location=USOR0304 --datatype=CN --refetch}
#${voffset 8}${font Helvetica LT Std :size=10}${color 707070}${goto 24}
${font Helvetica LT Std :size=8}${color whitesmoke}${goto 24}${execi 1800 conkyForecast -i --location=USOR0304 --datatype=CT}${voffset -10}${goto 200}${font Helvetica LT Std :size=25}${color d4d4d4}${execi 1800 conkyForecast -i --location=USOR0304 -u
--datatype=HT}
${voffset 35}${font Helvetica LT Std :size=8}${color white}${goto 34}${execi 600 conkyForecast -i --location=USOR0304 --datatype=HT -u --startday=1}/${color 707070}${execi 600 conkyForecast -i --location=USOR0304 --datatype=LT -u --startday=1}${font Helvetica LT Std :size=8}${color white}${goto 79}${execi 600 conkyForecast -i --location=USOR0304 --datatype=HT -u --startday=2}/${color 707070}${execi 600 conkyForecast -i --location=USOR0304 --datatype=LT -u --startday=2}${font Helvetica LT Std :size=8}${color white}${goto 128}${execi 600 conkyForecast -i --location=USOR0304 --datatype=HT -u --startday=3}/${color 707070}${execi 600 conkyForecast -i --location=USOR0304 --datatype=LT -u --startday=3}${font Helvetica LT Std :size=8}${color white}${goto 169}${execi 600 conkyForecast -i --location=USOR0304 --datatype=HT -u --startday=4}/${color 707070}${execi 600 conkyForecast -i --location=USOR0304 --datatype=LT -u --startday=4}
${font Helvetica LT Std :size=8}${color 707070}${goto 34}${execi 600 conkyForecast -i --location=USOR0304 --datatype=DW --shortweekday --startday=1}${font Helvetica LT Std :size=8}${color 707070}${goto 79}${execi 600 conkyForecast -i --location=USOR0304 --datatype=DW --shortweekday --startday=2}${font Helvetica LT Std :size=8}${color 707070}${goto 120}${execi 600 conkyForecast -i --location=USOR0304 --datatype=DW --shortweekday --startday=3}${font Helvetica LT Std :size=8}${color 707070}${goto 169}${execi 600 conkyForecast -i --location=USOR0304 --datatype=DW --shortweekday --startday=4}
${voffset -10}${font Helvetica LT Std :size=8}${color 707070}${goto 216}${execi 600 conkyForecast -i --location=USOR0304 --datatype=DW --shortweekday --startday=5}
${voffset -23}${font Helvetica LT Std :size=8}${color white}${goto 216}${execi 600 conkyForecast -i --location=USOR0304 --datatype=HT -u --startday=5}/${color 707070}${execi 600 conkyForecast -i --location=USOR0304 --datatype=LT -u --startday=5}
${image /home/kris/.images/base.png -p 12,30 -s 238x140}
${image /home/kris/.images/base.png -p 12,190 -s 238x40}
${image /home/kris/.images/flip_bg.png -p 30,10 -s 100x110}
${image /home/kris/.images/flip_bg.png -p 130,10 -s 100x110}
${execpi 600 conkyForecast -i --location=USOR0304 --template=/home/kris/.vreme.template}
####################################
###          Email Setup        ####
####################################
${voffset -52}${font WW2 BlackltrAlt:size=25}${color 014A7F}Current Emails & PC Vitals${color black}${hr 2}
${image /home/kris/.images/wlanbg2.png  -s 362x325 -p -10,240}
${voffset -9}${font OpenLogos:size=38}J${font Radio Space:size=22}${color yellow}${execpi 300 python ~/scripts/gmail_parser.py hornerkris@gmail.com June10th 3}${font Radio Space:size=14}${color 014A7F} New Message(s)
####################################
###       Battery Bar           ####
####################################
${color black}${font OpenLogos:size=26}T${color 014A7F}${font}  Battery: ${battery_percent}% ${battery_bar}
${color ffffff}${color black}${font OpenLogos:size=26}K${color 014A7F}${font}  CPU0: ${cpu cpu0}% ${cpubar cpu0}
${color black}${font OpenLogos:size=26}K${color 014A7F}${font}  CPU1: ${cpu cpu1}% ${cpubar cpu1}
${color black}${font OpenLogos:size=30}t${color 014A7F}${font}  Work:  ${uptime_short}
####################################
###         Network Info        ####
####################################
${voffset 16}${font WW2 BlackltrAlt:size=25}Network Info${color black}${hr 2}
${image /home/kris/.images/wlanbg2.png  -s 362x140 -p -10,533}
${alignc -10}${execpi /home/kris/wlanscript.sh}
${voffset -100}${font WW2 BlackltrAlt:size=13}${alignc -80}SSID: ${wireless_essid eth1}
${alignc -60}${font WW2 BlackltrAlt:size=13}Bitrate: ${wireless_bitrate eth1}
${alignc -48}${font WW2 BlackltrAlt:size=13}Local: ${addr eth1}
${alignc -35}${font WW2 BlackltrAlt:size=13}Public: ${execi 300 wget -q -O - checkip.dyndns.org | sed -e 's/[^[:digit:]\|.]//g'}
${voffset -20}${offset 44}${wireless_link_qual_perc eth1}%
${image /home/kris/.images/wlan100.png -p 20,550 -s 94x94}
${alignc -10}${execpi /home/kris/wlanscript.sh}
${font LT Oksana Medium:size=12}${execpi 300 /home/kris/verse.sh}
#! /bin/bash
function dload()
{   
    if [ $lq -le 100 ] && [ $lq -gt 65 ]; then
       echo '${image /home/kris/pix/wlan100.png -s 94x79 -p 10,520}'   
    fi   
    if [ $lq -le 66 ] && [ $lq -gt 55 ]; then   
       echo '${image /home/kris/pix/wlan50.png -s 94x79 -p 100,25}'   
    fi   
    if [ $lq -le 56 ] && [ $lq -gt 49 ]; then   
       echo '${image /home/kris/pix/wlan40.png -s 94x79 -p 100,25}'   
    fi   
    if [ $lq -le 50 ] && [ $lq -gt 5 ]; then   
       echo '${image /home/kris/pix/wlan5.png -s 94x79 -p 100,25}'   
    fi
}

function usage()
{
echo '${image /home/kris/pix/wlan0.png -s 94x79 -p 100,25}'
}


lq=$(sudo iwconfig eth1 | sed -n 's/.*Signal level[:=]-\([0-9]*\).*/\1/gp')

if [ $lq -le 5 ]
then
usage
else
dload
fi