Avinash
Avinash

Reputation: 13257

ssh command not running perl script

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?

Upvotes: 1

Views: 1631

Answers (3)

Nathan Fellman
Nathan Fellman

Reputation: 127428

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.

Upvotes: 2

ysth
ysth

Reputation: 98398

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

Upvotes: 5

Raskolnikoff Suzuki
Raskolnikoff Suzuki

Reputation: 1

ssh username@hostname '/tmp/testremote.pl'

Please try to add single quote to your command.

Upvotes: 0

Related Questions