[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Omaha.pm] Net::SSH::Perl and sudo or su



Here's the process I'm trying to follow.  I have this working with a
bash script btw, just thought I'd take an adventure into perl. :)

I'm trying to get my perl script to populate a serialnumber file by
sshing to the host and writing a file by one of 2 methods. (either way
root is inaccessible via ssh)

Method 1: write the file to /tmp and move it to /etc.
Method 2: write to /etc.

Regardless of how I do this I need to get root (via 'su' or vi 'sudo')
to get the file into /etc
All the file work is done on the remote client after sshing to it while
providing the information needed.
my $cmd = "echo \"HOST='$hos'\nASSET='$ass'\nSERIAL='$ser'\nMAKE='$mak'\nMODEL='$mod'\nFACILITY='$fac'\nRACK='$rac'\nUNITS='$uni'\" > $tmpf; sudo mv $tmpf /etc";

Hope this helps with a few questions.