Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re^3: run a perl script on a unix machine from a win machine

by salva (Canon)
on Dec 01, 2011 at 15:51 UTC ( [id://941103]=note: print w/replies, xml ) Need Help??


in reply to Re^2: run a perl script on a unix machine from a win machine
in thread run a perl script on a unix machine from a win machine

No, it doesn't work that way. You can only run shell commands there, not Perl code.

Though you can copy some Perl script there using scp and then run it, or even pass some perl code via stdio to a perl interpreter running on the remote machine.

For instance:

open(my $pipe, "plink /usr/bin/perl </some/local/script.pl |") or die "unable to run command: $!"; while (<$pipe>) { print "response: $_"; }

Replies are listed 'Best First'.
Re^4: run a perl script on a unix machine from a win machine
by Anonymous Monk on Jan 28, 2012 at 12:08 UTC
    I use ActivePerl+Net::SSH2 on WinXP to execute perlscript to remote hosts. 1. Connect to remote host $ssh->open(); 2. Open channel, start shell, $chan = $ssh->channel(); 3. Issue commands through the channel.. $chan->shell(); when I issue shell commands ie. "who" to the Linux machine, the data comes back through the channel. <$chan> I am using the linux machine as a jumpbox to further SSH to some cisco IOS switches. (firewall restriction) The problem I encounter is, when I issue "ssh -l username 10.1.1.1", nothing comes back through the channel. My script waits for a "Password:" which never reaches the channel. Any suggestions? PS. Same script works fine when issuing Cisco commands to directly SSH connected cisco switches.
      Any suggestions?

      Yes, is there any possibility you can run the script from a Linux box? Because doing this kind of sys admin tasks from Windows is an agony.

      Well, in any case, post your script source code.

      Can you install software on the Linux gateway or just allowed to run ssh in order to connect to the remote cisco?

        I work remotely, have to VPN into a network, SSH to the jumpbox(gateway, then ssh to actual cisco devices, only basic user access on the linux box

        Every week we have to capture bunch information from various sites' network devices, it is a manual intensive work which suits perlscript perfectly

        $chan->shell(); print $chan "ssh -l username 10.1.1.1\n"; while($buf=<$chan>){ if($buf =~ /"password:"/) { print $chan "password\n"; # got password prompt} else { exit; # export debug info, not reachable etc } } # # Once SSH into cisco switches, process cisco commands here # The actually commands are input from a separate file, # this is just an example. # print $chan "show tech\n"; print $chan "show version\n";

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://941103]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (3)
As of 2024-04-23 23:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found