in reply to
Solaris Another User Problem
Your description is a little confusing. I need some clarification:
- You have a set of commands you need to run on a production machine as user 'superuser' (ie, userid 0)
- You can do this interactively by
- logging onto the production machine as yourself
- executing 'sudo su superuser'
- executing the commands
- 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:
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";
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).