shell script for conky getting errors....


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting shell script for conky getting errors....
# 1  
Old 01-06-2012
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...

Code:
./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

Code:
#! /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

# 2  
Old 01-06-2012
For a test. Just after setting the value of $lq , try displaying the value:
Code:
echo "lq = $lq"

Assuming that the value is definitely an integer number, then lose the double quotes in all your integer comparisons.
# 3  
Old 01-06-2012
I dont want to sound stupid with this question, but where do you want me to set it in the code that I posted?
# 4  
Old 01-06-2012
I assume you want the Signal Level?

My iwconfig has values separated by "=".
Code:
root@bt > iwconfig wlan0|grep 'Link Quality=' 
          Link Quality=56/70  Signal level=-54 dBm

So, the following statement gives me the Signal Strength
Code:
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
Code:
root@bt > iwconfig wlan0 | sed -n 's/.*Signal level[:=]-\([0-9]*\).*/\1/gp'
56

Usage in your script would be
Code:
lp=$( iwconfig wlan0 | sed -n 's/.*Signal level[:=]-\([0-9]*\).*/\1/gp' )

--ahamed

Last edited by ahamed101; 01-06-2012 at 11:46 PM..
# 5  
Old 01-06-2012
So this was the output:

Code:
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...

Last edited by krisdeniseriley; 01-07-2012 at 12:06 AM..
# 6  
Old 01-07-2012
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
# 7  
Old 01-07-2012
So how could I get rid of the sudo way with the conky scripts?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Errors in if condition validations-Shell Script

Hello All, i am facing difficulty in validating the values, kindly help me in resolving the issue. Thanks a lot in advance. -Chandra Script:Test.sh #! /bin/sh # *************************************************************************** # Function to display help function usage()... (1 Reply)
Discussion started by: duddukuri
1 Replies

2. Shell Programming and Scripting

How to turn off ora errors in shell script?

I have a shell script which select total count from a table and use its value in a if condition like below connect_string="username/password@tnsname" tot=`sqlplus -s $connect_string << EOF set echo off set feedback off set head off select count(*) from test_table; EOF ` if then echo... (2 Replies)
Discussion started by: vel4ever
2 Replies

3. UNIX for Dummies Questions & Answers

Interpreting Shell Script errors when called from CRON

Hi All, I am calling a series of shell scripts via CRON so everything is running as root. However, in my error log file I am seeing the following errors. Please can anyone offer any advise as to the possible causes and solution to prevent the errors from appearing. The Error 1227 seems to... (2 Replies)
Discussion started by: daveu7
2 Replies

4. UNIX for Dummies Questions & Answers

Invalid option errors running shell script

The script below fails with the following error messages: gzip: invalid option -- 'w' Try `gzip --help' for more information. mysqldump: Got errno 32 on write cp: invalid option -- 'w' Try `cp --help' for more information. rm: invalid option -- 'w' Try `rm --help' for more information. ... (1 Reply)
Discussion started by: ANNACTION
1 Replies

5. Emergency UNIX and Linux Support

Seek help on shell script syntax errors

I want to delete archivelog files that has been archived and applied from primary database to standby database. This piece of script is working in Linux server. However, I copy it to Unix server with tiny modification. It won't work and generate the error message. I have checked code carefullt... (8 Replies)
Discussion started by: duke0001
8 Replies

6. Shell Programming and Scripting

Capture makefile errors in shell script

Hi, I have a bash script which calls a few "make". I would like to know whether the makefile failed with any errors. How do I do that in the script? Thanks, S (2 Replies)
Discussion started by: suryaemlinux
2 Replies

7. Shell Programming and Scripting

Bad substitution errors in shell script

Hello, I was hoping for a second pair of eyes or a little bit of help figuring out what my error is in a script. I did some searching in the forums and didn't find anything so please forgive me if it a similar problem has been discussed before. My script accepts normal user arguments; however,... (2 Replies)
Discussion started by: Jackinthemox
2 Replies

8. Shell Programming and Scripting

Help with shell script errors

hey watsup guys i am new in the shell script world. so i need help fom you guys, i have written these two codes and they both give the same errors( expr : syntax error). Code 1 : #! /bin/sh # count1 appends an increment to a file 200 times # note that a file called numbers must be... (5 Replies)
Discussion started by: surubi_abada
5 Replies

9. Shell Programming and Scripting

Parse for errors shell script

All, I have a shell script which parses the /var/adm/messages file for errors every 15 minutes as a cron job. The script runs at 01, 16, 31, and 46 minutes every hour. The problem is if the error is encountered any time during the beginning of hour I can get paged three times. I would like to... (2 Replies)
Discussion started by: bubba112557
2 Replies

10. Shell Programming and Scripting

Showing errors when connecting to sqlplus in shell script

hi, I am trying to automate the compilation of procedures stored in .sql files in Unix. Is there any way in which we can sho err if there errors are raised in the compilation? I am using the following code to connect to the sqlplus sqlplus ${SQL_USER}/${SQL_PASSWORD} (5 Replies)
Discussion started by: silas.john
5 Replies
Login or Register to Ask a Question