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
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).#! /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
fnord
In Section
Seekers of Perl Wisdom