3 ms·
ssh will read commands from stdin so this will work: echo "cd /tmp && pwd" | ssh localhost Or with a here string that bash and a few others support:
by rascul 3y ago
ssh will read commands from stdin so this will work:
echo "cd /tmp && pwd" | ssh localhost
Or with a here string that bash and a few others support:
ssh localhost <<<"cd /tmp && pwd"
I often use the here string method. Maybe one of those would be easier to remember.
- mst 3y agoOooh, the here string reads nicely to me and would require less thought about quoting/interpolation choices which is a win on its own even if it still takes me multiple attempts to remember to do that. Much appreciated.