Perl-Sensitive Sunglasses | |
PerlMonks |
Trapping sudo failures via Net::OpenSSHby rastoboy (Monk) |
on Mar 04, 2011 at 19:42 UTC ( [id://891505]=perlquestion: print w/replies, xml ) | Need Help?? |
rastoboy has asked for the wisdom of the Perl Monks concerning the following question:
Greetings Brothers,
I'm having a surprisingly agonizing time trapping sudo failures via the awesome Net::OpenSSH module. I've been trying it by using Expect, which I posted about here: No matter what I do, success works great--successful sudos are not a problem--and I can even trap failures--but once I've failed to sudo I can't do any more Net::OpenSSH commands, and in fact the whole program comes to a screaching halt, unless I ctrl-c or interact in some other way, since it is prompting for another password try. What I would like to do (I think) is simply attempt to sudo, close that connection, and then try again, this time capturing the output. If I get the expected output, then I know the sudo attempt worked. If I don't, then I need to do something else. Here is what I'm trying currently: The first machine has a different sudo password, and thus will fail. But when I try this I get: And if I hit ctrl-c I'll get the password prompt: What I'm kinda thinking is that one of the very cool features of Net::OpenSSH, which I've made heavy use of (thank you Salva!), is that it automagically prompts you if a remote machine puts up a sudo password prompt during a session, and it Just Works. So it's like attaching/re-attaching STDIN, STDOUT intelligently (I presume). But now that functionality is getting in my way?
Back to
Seekers of Perl Wisdom
|
|