开发者

ssh command not running perl script

I have following perl script

#!/usr/bin/perl
$userinput =  <STDIN>;
chomp ($userinput);
while ( $user开发者_StackOverflow中文版input 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?


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


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.


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

Please try to add single quote to your command.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜