Linux Tcsetattr Input Output Error
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site ssh tcsetattr: input/output error About Us Learn more about Stack Overflow the company Business Learn more about
/dev/ttys0: Tcgetattr: Input/output Error
hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join tcsetattr example the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Perl's backticks/system giving “tcsetattr:
Tcsetattr Invalid Argument
Input/output error” up vote 2 down vote favorite 1 I'm writing a perl script that kicks off a script on several different servers using ssh. The remote script needs to run as long as this 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 ioctl = 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: Input/output error Connection to server01 closed. The same result occurs when running with system (and backticks are preferred anyways since I want the output of the script). When I run the exact command between the backticks on the command line, it works exactly as expected. What is causing this? perl ssh share|improve this question asked May 13 '11 at 20:27 dc. 1,10921428 add a comment| 2 Answers 2 active oldest votes up vote 3 down vote accepted The tcsetattr: Input/output error message comes from ssh when it tries to put the local terminal into “raw” mode (which involves a call to tcsetattr; see enter_raw_mode in sshtty.c, called from client_loop in clientloop.c). From IEEE Std 1003.1, 2004 (Posix) Section 11.1.4: Terminal Access Control, tcsetattr may return -1 with errno == EIO (i.e. “Input/output error”) if the
set baud rate Synopsis #include
Q&A Tutorials Poetry RecentThreads NewestNodes Donate What'sNew on Feb 27, 2011 at 18:33UTC ( #890441=perlquestion: print w/replies, xml ) Need Help?? rastoboy has asked for the wisdom of the Perl Monks concerning the following question: Greetings, Brothers! http://www.perlmonks.org/?node_id=890441 I have no doubt my lack of Linux knowledge is seriously hampering me in my attempts to automate checking for sudo access on remote machines--any help would be greatly appreciated! Basically, the idea is that if I have the current user password, that is success, and if not I want to drop into interactive mode to set it correctly (I won't bore output error you with the grisly why's and wherefores) I have a simple method that attempts to do this: sub checksudo { my ($ssh, $ip, $pass) = @_; #$ssh is the successfully created openssh +object, $pass is the user's sudo password my $system = $ssh->system ('sudo -K') or return "failed to sudo -K: $! +\n"; #ensure we are prompted for a password my ( $pty, linux tcsetattr input $pid ) = $ssh->open2pty( "sudo -p 'configtest:' bash 2>&1") or return "failed to attempt sudo bash: $!\n"; my $expect = Expect->init($pty); #sleep 1; #$expect->send ($pass . "\n"); $expect->expect(2, [ qr/configtest:/ => sub { my $expect =shift; $expect->send($p +ass . "\n"); exp_continue;} ], [ qr/Sorry/ => sub { my $expect=shift; print "Failed\n"; e +xp_continue; } ], ); #$expect->interact(); return; } [download] The above code gives me:tcsetattr: Input/output error [download] If I comment out the first array ref in the $expect->expect() statement, I get:tcsetattr: Input/output error channel 0: chan_read_failed for istate 1 [download] However, if I remove the $expect->expect() statement entirely and uncomment the $expect->send() statement which just sends the password, I get successful sudo's on the remote machine. Likewise if I only have the $expect->interact() statement in place, that works just fine, too. I have to think I'm fundamentally misunderstanding something--any input would be greatly appreciated! updateEven when things seem to go fine, it seems that I still get the I/O errors when I try to execute another remote ssh command. The command succeeds but when that error at the top. I can't seem in the