Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re^4: Automating sudo actions

by andal (Hermit)
on Jan 25, 2011 at 16:03 UTC ( #884160=note: print w/ replies, xml ) Need Help??


in reply to Re^3: Automating sudo actions
in thread Automating sudo actions

Thanks for all the great suggestions. Unfortunately, changing the environment is quite impossible. I'm stuck having to 'sudo bash'. If I can't automate through that (icky) interface, I'm stuck largely copy/pasting chunks of commands.

Why are you stuck to 'sudo bash'? Why can't you do `sudo perl_script`?

Well, even if you can't control sudo configuration and only "bash" is available for execution, then try something like

my $pid = open(OUT, "|-"); die "Can't fork\n" unless defined $pid; if(!$pid) { exec "sudo bash"; die "oops no exec\n"; } select OUT; $| = 1; print "echo hi there\nexit\n"; close(OUT);
Read perldoc perlipc. Section Bidirectional Communication with Another Process. Maybe this will help you to do simple automation.


Comment on Re^4: Automating sudo actions
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://884160]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (11)
As of 2015-07-07 23:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (93 votes), past polls