I have a list of servers 20+ that I would like to get the shell that they are using. While logged onto a server I can run the following command
$ ps -p $$ PID TTY TIME CMD 12022 pts/6 00:00:00 bash
Instead of touching each server and doing this I tried to loop it with a list
$ for i in `cat servlist`; do echo $i ; ssh $i ps -p $$ ; done serv1 PID TTY TIME CMD serv2 PID TTY TIME CMD serv3 PID TTY TIME CMD
Looping this does not show the expected output. I then tried to ssh to a single server and run the command but got the same error.
$ ssh serv4 ps -p $$ PID TTY TIME CMD
Why is this happening, nothing jumps out at me in the ssh man pages.