Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

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).


Log In?

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

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (3)
As of 2022-01-17 04:10 GMT
Find Nodes?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:

    Results (51 votes). Check out past polls.