Skip to main content
1 of 3

Execute command on remote host fails

I'm trying to execute some commands on remote host like this :

ssh -t -t -l user 172.20.20.20 <<EOF
  pid=$(ps -ef | grep [a]pp-management | awk '{print $2}') && kill -9 $pid && rm -rf CI/*
EOF

What happens is that I remain logged at remote server and the kill is not executed :

user@ubuntu:~$ pid= && kill -9  && rm -rf CI/*
kill: usage: kill [-s sigspec | -n signum | -sigspec] pid | jobspec ... or kill -l [sigspec]

Neither rm gets executed, what am I doing wrong? I see that nothing get passed to kill -9 command, why is this?