Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

calling on files to execute remotely

by RayRay459 (Pilgrim)
on Aug 24, 2001 at 03:52 UTC ( #107556=perlquestion: print w/replies, xml ) Need Help??

RayRay459 has asked for the wisdom of the Perl Monks concerning the following question:

Is there a way for perl to call on a file that is sitting on a remote machine to execute with out WMI or RSH or SSH. Is there a way to do it with a cgi script or some other perlish way. If anyone has any ideas, i would greatly appreciate them. This is for a Win32 environment. Ray

Replies are listed 'Best First'.
Re: calling on files to execute remotely
by perrin (Chancellor) on Aug 24, 2001 at 03:58 UTC
    Why not just make a CGI wrapper around the program that you want to execute? Or use SOAP?
      Thank you all for your comments. Being fairly new to Perl, i do not know how to use a cgi wrapper or SOAP. do you or anyone else have any examples. Anything will help. Thanks, Ray
        For SOAP, you might want to start here. CGI information is all over the place. You could buy a book, like this one, or read one of the thousands of free ones on-line.
Re: calling on files to execute remotely
by jlongino (Parson) on Aug 24, 2001 at 07:22 UTC
    I'm not sure if I understand exactly what you want to do, but you could use the cmd method of Net::Telnet. The code would look something like this:
    use Net::Telnet (); my $tn = Net::Telnet->new(Timeout => 15, Prompt => '/host:\/home\/dir\ +>/'); my $host = 'some.host.xxx'; my $login = 'test'; my $passwd = 'testpw'; $tn->open($host); $tn->login($login, $passwd); my $msg = $tn->errmsg; if ($msg) { print "A system error was generated on the login attempt:\n"; print " '$msg'\n\n"; } my @list = $tn->cmd("./prog.p"); my $msg = $tn->errmsg; if ($msg) { print "A error occurred when attempting remote cmd './prog.p':\n"; print " '$msg'\n\n"; } my $ok = $tn->close; if (not $ok) { print "\nUnable to close Telnet connection to HOST: $host\n\n"; exit; }
    Hope this helps.

    If the code and the comments disagree, then both are probably wrong. -- Norm Schryer

Re: calling on files to execute remotely
by $code or die (Deacon) on Aug 24, 2001 at 06:27 UTC
    You can do it with WMI. You'll need to use Win32::OLE to access it. I don't have any code for that, but if you look in MSDN - you'll find the WMI schema. It's fairly complicated - you'll probably need to run the script as member of administrators group

    You could also just use psexec from Sysinternals (the PSTools suite).

    Or you could take perrin's excellent advice and just use CGI on the remote server - use a password protected directory and encrypt login with SSL.

    Error: Keyboard not attached. Press F1 to continue.
Re: calling on files to execute remotely
by joefission (Monk) on Aug 24, 2001 at 07:43 UTC
    The easiest way is to remotely schedule a job to run on that machine. Assuming that you have admin rights on the remote box that will be running the script...

    Win32::AdminMisc should do the trick.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://107556]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (7)
As of 2020-08-10 08:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Which rocket would you take to Mars?










    Results (56 votes). Check out past polls.

    Notices?