1

I have following perl script

#!/usr/bin/perl
$userinput =  <STDIN>;
chomp ($userinput);
while ( $userinput ne "DONE")
{
        print STDOUT "User typed ----->  $userinput\n";
        $userinput =  <STDIN>;
        chomp ($userinput);
}

I have copied this on on unix box, locally this works fine but when I try to run this perl script remotely from another box using ssh, it does not work.

I am running this script using following command.

ssh username@hostname /tmp/testremote.pl

It just hangs on the STDIN and does not return anything.

Any idea why this is not working?

1
  • Just to be clear: /tmp/testremote.pl must exist on the remote machine -- does it? Commented Dec 29, 2010 at 6:36

3 Answers 3

5

Try adding $|=1; after the #! line.

Sign up to request clarification or add additional context in comments.

Comments

2

your terminal's STDIN is probably not being redirected correctly to the remote terminal.

You can try:

ssh username@hostname 'echo bla bla bla | /tmp/testremote.pl'

And if this works it will indicate that the perl script is fine, but the problem is your redirection.

1 Comment

Would be a good test if not for the single quote after the last "bla".
0
ssh username@hostname '/tmp/testremote.pl'

Please try to add single quote to your command.

1 Comment

That will only help if the command being sent to ssh requires shell interpolation.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.