
blues
New User
Jul 26, 2012, 11:22 AM
Post #1 of 6
(3372 views)
|
Creating Remote Directories with a wrapper
|
Can't Post
|
|
I have a script that pushes out a perl script to multiple machines and collects system information. These are all Solaris 10 spare servers. Everything works great accept my directory creation on the remote machine. If I login and run it manually it works fine, but does not work when I run it from my wrapper script. My system_info.pl is copied to /tmp on the remote machine using scp and expect. It then runs with sudo locally. Here are a few lines from the wrapper and system_info script. my wrapper contains the following sudo command to execute the system_info.pl locally.
$sudo_cmd = "cd /tmp ; sudo perl system_info.pl ; exit"; and here is part of the expect piece that runs the command
[ qr/admin\@$server\s*\$\s/ => sub { $cmd->send("$sudo_cmd\n"); } ], The system_info.pl script that is copied contain's the following lines to create the directory. Again tis works if I login and run system_info.pl manually, but not remotely with the wrapper.
if (-d "/usr/local/adm/log") { open MYLOG, "+>", "/usr/local/adm/log/system_info.log" or die $!; } else { mkdir ("/usr/local/adm", 0755); mkdir ("/usr/local/adm/log", 0755); open MYLOG, "+>>", "/usr/local/adm/log/system_info.log" or die $!; } Any help would be appreciated. Thank you -blues
|