Psexec from sysinternals.

Here's some perl that uses Win32::AdminMisc routines to create a
scheduled job to run in 120 seconds. The caveat is that this runs as the
local machine account - it can't access remote files.

sub schedule {

        my $host = shift;
        my $file = shift;

        my $offset = CalcOffset($host);
# delta (seconds) of remote TZ
        if( $offset == -1 ) {
                $mesg .= "Could not calculate TZ delta for $host\n";
                return;
        }

        my $DOM = 0;
        my $DOW = 0;
        my $flags = JOB_ADD_CURRENT_DATE;
        my $cmd = $file;
        my $Time = Win32::AdminMisc::GetTOD("\\\\$host") + 120 +
$offset;
        my $job = Win32::AdminMisc::ScheduleAdd("\\\\$host", $Time,
$DOM, $DOW, $flags, $cmd);
}

########################################################################
##################
#
# Subroutine CalcOffset
# Calculates the number of seconds difference between the local time of
this system and
# the local time of the remote server.
#
########################################################################
##################

sub CalcOffset {

        my $remote = shift;
        my %info_local;
        my %info_remote;

        Win32::Lanman::NetRemoteTOD("", \%info_local) or return -1;
        Win32::Lanman::NetRemoteTOD($remote, \%info_remote) or return
-1;

        return 60 * ($info_local{timezone} - $info_remote{timezone});
}
 

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Daniel
Rychlik
Sent: Wednesday, April 26, 2006 10:33 AM
To: $Bill Luebkert
Cc: [email protected]
Subject: RE: Executing Remotely

So there is no real easy way to execute programs or batch files from
PERL...  We would have to physically touch all 2000 servers to execute
these upgrade scripts...  

Hmmm... has to be a better way.


-----Original Message-----
From: $Bill Luebkert [mailto:[EMAIL PROTECTED]
Sent: Monday, April 24, 2006 8:30 PM
To: Daniel Rychlik
Cc: [email protected]
Subject: Re: Executing Remotely

Daniel Rychlik wrote:

> How would one execute a batch or executable on a remote computer using

> PERL?

rsh or ssh or a server running on the remote computer (eg: web server
w/CGI interface, SNMP, etc) - lots of ways depending on your needs.

_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to