Demian, I'm not sure what's wrong with your quotes. The only problem I can see with your script is that the way you end every line with a semi colon and then a backslash (
; \) accomplishes nothing (they in fact cancel each other out to produce the same effect as if there was nothing there).
Uhm, yeah, I guess that's a bit redundant. You're right, the above script works. But now I have to call the script like this: sh -c 'script goes here'. So I need to quote the whole thing again. Well, actually I want to call this script with the PipeRead command from within an fvwm menu which basically is equivalent to the sh -c thing. So the menu item looks like this:
Code:
AddToFunc MakeDesktopMenu
+ I DestroyMenu recreate DesktopMenu
+ I PipeRead 'gkrellmPID=`ps ax|grep [g]krellm|awk \'{print $1}\'`; \
* * *if [ -z ${gkrellmPID} ]; \
* * * * * *then echo "AddToMenu DesktopMenu Start-gkrellm Exec exec gkrellm -g +0+460"; \
* * * * * *else echo "AddToMenu DesktopMenu Stop-gkrellm Exec exec kill $gkrellmPID"; \
* * *fi;'
Actually I realize that I do need the ; \ because otherwise fvwm tries to interpret the lines stating with if, then,... and doesn't know what to do. Anyway, I tried to escape the single quotes around the awk "script" but that doesn't work. The message that's spit to the console from the above script is sh: [: too many arguments.
I was thinking of an alternative way to get the PID of a program that doesn't require two different sets of quotes but couldn't com up with anything.
Bookmarks