the following command looks properly quoted and escaped:
$ echo -e ssh -q rmthost 'bash -c "ps -ef|grep '\'''\\\<'defunct'\\\>''\''|grep -v grep|awk '\'''{print \$1}''\'' "'
ssh -q sbpsvrwm757 bash -c "ps -ef|grep '\'|grep -v grep|awk '{print $1}' "
but when executed, the result is not what is expected:
$ ssh -q rmthost 'bash -c "ps -ef|grep '\'''\\\<'defunct'\\\>''\''|grep -v grep|awk '\'''{print \$1}''\'' "'
root16986 16982 0 - ? 0:01
the awk command didn't seem to extract the right column.
Now I followed the link provided by Siguza and came up with:
$ echo ssh -q rmthost "'"bash -c '"ps -ef|grep '"'\'|grep -v grep|awk '{print \$1}'"'"'"'"
ssh -q rmthost 'bash -c "ps -ef|grep '\'|grep -v grep|awk '{print $1}'"'
that looks perfectly escaped too, but still doesn't work:
$ ssh -q rmthost "'"bash -c '"ps -ef|grep '"'\'|grep -v grep|awk '{print \$1}'"'"'"'"
Missing }
or,
$ echo ssh -q rmthost bash -c '"ps -ef|grep '"'\'|grep -v grep|awk '{print \$1}'"'"'
ssh -q rmthost bash -c "ps -ef|grep '\'|grep -v grep|awk '{print $1}'"
$ ssh -q rmthost bash -c '"ps -ef|grep '"'\'|grep -v grep|awk '{print \$1}'"'"'
root 16986 16982 0 - ? 0:01
or,
$ echo ssh -q rmthost "bash -c \"ps -ef |grep '\'|grep -v grep| awk '{print \$1}'\""
ssh -q rmthost bash -c "ps -ef |grep '\'|grep -v grep| awk '{print $1}'"
$ ssh -q rmthost "bash -c \"ps -ef |grep '\'|grep -v grep| awk '{print \$1}'\""
root 16986 16982 0 - ? 0:01
any idea why?
Please note that I need bash -c to enable bash-style output redirection like >/var/tmp/1.ouy 2>&1 for the command.
your help is appreciated.
No comments:
Post a Comment