Take the tour ×

How can I do something like this with one ssh command:

echo << EOF
echo "Choose a file:" *
read f
rm -r "$f"
EOF | ssh user@host

I can use the -tt (yes two t's) with ssh to make ssh read from stdin, however it doesn't seem to allow read to work.

Is there a way of doing this?

share|improve this question
I don't get what your "like this"-command should be an example for.. –  Karma Fusebox Feb 18 at 0:12
@KarmaFusebox I added a better example. –  Tyilo Feb 18 at 0:46
add comment

1 Answer

up vote 2 down vote accepted

If I understand your example command correctly, this should work:

ssh user@host 'echo "Input something:"; read VAR; echo "Got: $VAR"'              

That worked when "host" was a Slackware Linux server, and ssh ran on an Arch linux laptop. My shell on the Slackware server is zsh 4.2.6 (i486-slackware-linux-gnu). Since read is a shell built-in, I imagine that choice of shell could have something to do with it.

share|improve this answer
add comment

Your Answer


