Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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 '13 at 0:12
    
@KarmaFusebox I added a better example. –  Tyilo Feb 18 '13 at 0:46

1 Answer 1

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.