ssh remote command parsing gone wrong
I tried this out myself and debugged by inserting an echo command:
ssh -t [email protected] "ps -A | grep rsyslogd | awk '{print $1}' | xargs -I{} echo gdbserver --attach 0.0.0.0:52159 {}"
The last part that should have been just the PID was instead:
1209 ? 00:00:05 rsyslogd
My guess is that the $ sign in the awk was being interpreted by bash somewhere and turned into an empty string, so the awk command was just {print}
.
Adding a backslash before the $ fixed it and produced a final command that includes just the PID.
ssh -t [email protected] "ps -A | grep rsyslogd | awk '{print \$1}' | xargs -I{} echo gdbserver --attach 0.0.0.0:52159 {}"