Results 1 to 5 of 5
Hey,
the following shell script executes but does absolutely nothing. It is meant to switch the synaptics touch pad on if it's off or off if it's on. Any ideas? ...
- 08-26-2007 #1
A little help with a shell script
Hey,
the following shell script executes but does absolutely nothing. It is meant to switch the synaptics touch pad on if it's off or off if it's on. Any ideas? I think it's something to do with the string comparison.
Thanks in advance,Code:question="`synclient -l | grep TouchpadOff`" echo $question if [[ $question == "TouchpadOff = 1" ]] then synclient TouchpadOff=0 else synclient TouchpadOff=1 fi
chadders.
- 08-26-2007 #2
Read this:
http://www.tldp.org/LDP/abs/html/sha-bang.html
Also, run your script like so:
bash -x ./script-here
You can watch it as it executes to see which statements are being run, variable assignments, etc.
- 08-26-2007 #3
Help? To me it appears as though a list of characters is being compared to a string (if it's even a string). How can I rectify this?
Code:chadders@laptop:~/Desktop$ bash -x touchpad.sh ++ synclient -l ++ grep TouchpadOff + question=' TouchpadOff = 1' + echo TouchpadOff = 1 TouchpadOff = 1 + [[ TouchpadOff = 1 == \T\o\u\c\h\p\a\d\O\f\f\ \=\ \1 ]] + synclient TouchpadOff=1
- 08-26-2007 #4
Don't forget to add your sha-bang.
I think the problem is with whitespace in the left side of your conditional test. Try this:
[[ $(echo $question | tr -d ' ') == 'TouchpadOff=1' ]]
Squeeze out the spaces so that you can compare easily.
See how helpful that debugger is?
You can see the white space in the variable assignment operation.
- 08-27-2007 #5


Reply With Quote