I've got two hosts, the first sends command via ssh. The second executes that command and prints output to my xterm:
user@host_one:~# ssh user@host_two "ls"
user@host_two's password:
Document Downloads Music Pictures Videos
I want to get the text of remote command, in my case it's "ls", on my 'host_two'. Then my /etc/bash.bashrc script on 'host_two' will get the text of that command and will do something with it.
For example, my /etc/bash.bashrc will do smth like that:
if [ -z "$PS1" ] # PS1 is my own global variable that is set only if it's a non-interaction session
then
echo $COMMAND_GOT_VIA_SSH
fi
Then I expect to get smth like this:
user@host_one:~# ssh user@host_two "ls"
user@host_two's password:
ls