Results 1 to 4 of 4
Hi,
I'm having a total memory blank to why this is happening. I get the error
"line 7: [: $save: integer expression expected"
It's a simple script and I'm having ...
- 08-29-2009 #1Just Joined!
- Join Date
- Dec 2006
- Posts
- 12
Simple problem - Bash script
Hi,
I'm having a total memory blank to why this is happening. I get the error
"line 7: [: $save: integer expression expected"
It's a simple script and I'm having a total memory blank. Any ideas?
#!/bin/bash
zenity --info --text="This will now display all open files."
gksudo lsof | zenity --text-info --width 530
save=$(zenity --question --text="Would you like to save this list?")
if [ '$save' -eq '0' ]
then
szSavePath=$(zenity --file-selection --save --confirm-overwrite)
gksudo lsof > $szSavePath
fi
./main.sh
exit 0
Thanks, Shaun.
- 08-29-2009 #2Linux Newbie
- Join Date
- Jan 2008
- Location
- Canada
- Posts
- 109
Hi Shauntp
For whatever reason the return value for the variable 'save' is not an integer.
save=$(zenity --question --text="Would you like to save this list?") <--- make sure that the value returned by the assignment you made, is an Integer Value and not a Ascii 0 place holder. This means that although the value may be zero it is not an integer variable but rather a character variable. Hope this helps. Cheers...
Robert
- 08-29-2009 #3
You are comparing a literal $save with 0. Variables are not expanded inside single quotes.
A second problem is that $save contains the output of zenity -- and there is none. The return code contains the value you want.Code:if [ "$save" -eq 0 ]
Code:zenity --question --text="Would you like to save this list?" if [ $? -eq 0 ]
- 08-29-2009 #4Just Joined!
- Join Date
- Dec 2006
- Posts
- 12
Thankyou! It worked.


Reply With Quote
