Perl backticks / system giving "tcsetattr: I / O Error"

I am writing a perl script that runs a script on several different servers using ssh. The remote script should work as long as the script is running:

#!/usr/bin/perl
require 'config.cfg'

#@servers is defined in config.cfg
#Contains server info as [username,hostname]
#
# @servers = ([username,server1.test.com],[username,server2.test.com]) 
#
foreach $server ( @servers ) {
    my $pid = fork();
    if ( $pid == 0 ) {
        $u = ${$server}[0];
        $h = ${$server}[1];
        print "Running script on $h \n";
        print `ssh -tl $u $h perl /opt/scripts/somescript.pl`;
        exit 0;
    } else {
        die "Couldn't start the process: $!\n";
    }
}
[...]

When I run this script, I get the following output:

./brokenscript.pl
Running script on server01
$ tcsetattr: I / O error.
Connection to server1 closed.

The same result occurs when starting from system(and backlinks are preferred anyway, since I want the output of the script). When I run the exact command between the return windows on the command line, it works exactly as expected. What causes this?

+3
source share
2 answers

tcsetattr: Input/output error ssh, "" ( tcsetattr, . enter_raw_mode sshtty.c, client_loop clientloop.c).

IEEE Std 1003.1, 2004 (Posix) 11.1.4: , tcsetattr -1 errno == EIO ( .. " /" ), ( ?).

ssh , (- script ( , )).

, ssh -ntt ( stdin /dev/null, tty ) ssh -t ( -l , , ).


, script, . wait ( "" ), , ( , ). -n, , , ssh, , ( ) .

script do sleep 30 , , ssh , . , . wait ( ).

+4

, , SSH tty, stdin/stdout ttys. SSH tty (, ), .

, tty?

1 SSH?

0

All Articles