Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Running exe's remotely

by wahoowa (Novice)
on Jan 30, 2003 at 16:06 UTC ( #231354=perlquestion: print w/replies, xml ) Need Help??

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

I'm trying to run an executable located on a remote Win2k server, for that server. I'm getting errors about the exe only being able to run on win2k machines. The machine I'm running the script from is a NT4 machine, but I need the exe to run on that remote server. I've mapped and tried 'chdir', etc. here's my last attempt.
system ("net use J\: \\\\$hostname\\c\$"); chdir 'j:\abc\agent\config'; my $ldconfig = 'j:\abc\agent\config\config.exe'; system ("$ldconfig");

Replies are listed 'Best First'.
Re: Running exe's remotely
by zakb (Pilgrim) on Jan 30, 2003 at 16:17 UTC

    All your combination of chdir's and system's is doing is running the executable from the network on your machine.

    You need to use something like telnet (Net::Telnet?) to log in to the remote machine and run the executable on that machine. Of course, you'll need a telnet server on the Win2k machine.

      I use a Workstation module I wrote myself. one of the subs returns a WMI handle...

      sub get_wmi {
              my $self = shift;
              my $name = $self->name or do { 
                      warn("Cannot return WMI handle for anonymous workstation.\n");
                      return 0; 
                      };
              use Win32::OLE ;
              my $wmi = Win32::OLE->GetObject( "winmgmts:{impersonationLevel=impersonate,(security)}//$name");
              if ($wmi) {
                    return $wmi;        
              }else{
                    return 0;
              }   
      }
      
      You should then be able to do $wmi->CreateProcess("your.exe") or whatever (see MSDN.microsoft.com for details of WMI)...

      Or Google for "perl+WMI" - or visit www.roth.net/perl/scripts

Re: Running exe's remotely
by MZSanford (Curate) on Jan 30, 2003 at 18:22 UTC
    If you have the NT Resource Kit, take a look at rcmd ... it runs commands on the remote machine.
    from the frivolous to the serious
      PSExec

      www.sysinternals.com

      Very useful and easier than my WMI solution - doesn't use much Perl, though :-(

      rcmd was a good idea, but unfortunately it's not installed on the remote win2k server....any other ideas?
Re: Running exe's remotely
by HamNRye (Monk) on Jan 30, 2003 at 20:46 UTC

    There are also various 'rsh' implementations for the windows platform. That is what we use here....

    http://home.us.net/~silviu/rshd/readme.txt is the one we personally use.

    ~Hammy

Re: Running exe's remotely
by pg (Canon) on Jan 31, 2003 at 04:03 UTC
    One more option. I use VNC, you can take a look at their web site: VNC
Re: Running exe's remotely
by Skeptic (Initiate) on Jan 31, 2003 at 19:54 UTC
    My vote is for Rcmd... its only a file, maybe two to copy. If you don't have the reskit just laying around then the PStools are the way to go. That's if you want to take care of biz in short order.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://231354]
Approved by Helter
Front-paged by tye
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (4)
As of 2022-09-29 10:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I prefer my indexes to start at:




    Results (125 votes). Check out past polls.

    Notices?