I am trying to run a few commands through ssh
and getting confused with the behavior of sh -c
:
ssh myhost sh -c 'echo starting; who -b; date; echo $SHELL'
Output (note: the echo's output is just a blank line!)
system boot 2016-12-22 20:22
Thu Jan 26 06:12:52 UTC 2017
/bin/bash
Without sh -c
I get the correct output:
ssh myhost 'echo starting; who -b; date; echo $SHELL'
Output:
starting
system boot 2016-12-22 20:22
Thu Jan 26 06:18:28 UTC 2017
/bin/bash
Questions:
- Why doesn't
sh -c
handle theecho starting
command correctly? It outputs a blank line. - Why is SHELL set to
/bin/bash
even withsh -c
?