Here is the command I have which works
It's just a kill with an expression which returns a number
kill $(ps -ef | grep '[m]atchbox-panel --titlebar --start-applets showdesktop,windowselector' | cut -f8 -d' ') &> /dev/null
Here is the ssh I normally use
bash -c 'timeout 120s ssh -o StrictHostKeyChecking=no [email protected] "cd NightTest"'
I try to combine both of them
bash -c 'timeout 120s ssh -o StrictHostKeyChecking=no [email protected] "kill $(ps -ef | grep '[m]atchbox-panel --titlebar --start-applets showdesktop,windowselector' | cut -f8 -d' ') &> /dev/null"'
It doesn't work, my guess is that it gets mixed up with the ''.
Tried options
Escaping most of the ' in the kill commands :
bash -c 'timeout 120s ssh -o StrictHostKeyChecking=no [email protected] "kill $(ps -ef | grep \'[m]atchbox-panel --titlebar --start-applets showdesktop,windowselector\' | cut -f8 -d\' ') &> /dev/null"'
Do not work either, I did many other tries but can't make it work.
Any ideas?
Added note
My system doesn't support pkill command
bash -c '…'notation in the first place? Why not justtimeout …? Using the single quotes for thebash -c '…'greatly complicates the processing. You need to get a level of single quotes around the command to be executed.$(ps …)on the local machine, not on the host you aressh-connecting to.