Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: Solaris Another User Problem

by Illuminatus (Curate)
on Dec 19, 2012 at 18:25 UTC ( #1009597=note: print w/ replies, xml ) Need Help??


in reply to Solaris Another User Problem

Your description is a little confusing. I need some clarification:

  1. You have a set of commands you need to run on a production machine as user 'superuser' (ie, userid 0)
  2. You can do this interactively by
    • logging onto the production machine as yourself
    • executing 'sudo su superuser'
    • executing the commands
  3. You have attempted to write a perl script to connect to the production machine and do this, but cannot figure out the logic
it would be helpful if you provided a sample of what you've tried in Net::SSH::Expect. I have made a lot of assumptions here, but if they are correct, it boils down to attempting to execute the commands as 'superuser'. The easiest way I can think of to do this would be something like:
#! /usr/bin/perl use strict; use warnings; use Fcntl qw( :mode ); # other code here... my $file = "/tmp/su.cmds"; open (CMDS, ">$file"); print CMDS "#! /bin/bash\n"; print CMDS "command 1\n"; print CMDS "command 2\n"; close CMDS; chmod S_IRWXU | S_IXGRP | S_IXOTH, $file; system ("sudo superuser $file"); # script continues
This script obviously assumes you can run a perl script on the target system. You could just as easily do these using 'shell commands' via Expect (ie create a command file and use 'sudo superuser cmdfile' to run it).

fnord


Comment on Re: Solaris Another User Problem
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (11)
As of 2015-07-29 02:54 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 (260 votes), past polls