Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

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

by akrrs7 (Acolyte)
on Dec 01, 2011 at 15:37 UTC ( [id://941097]=note: print w/replies, xml ) Need Help??


in reply to Re: 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

I'm guessing the $cmd can also be some function ??? The commands are the rest of the perl script...which I could lump as a single function.
  • Comment on Re^2: run a perl script on a unix machine from a win machine

Replies are listed 'Best First'.
Re^3: run a perl script on a unix machine from a win machine
by marto (Cardinal) on Dec 01, 2011 at 15:40 UTC

    For clarificaiton, are you expecting to use plink (via system) to connect to the unix server then the remainder of your perl script should be executed by the unix server?

      Yes...that is exactly what I would like to achieve.

        Then this isn't going to work. You should read and understand what plink does, and think about how perl works too. IMHO you should write a script which copies your file to the target servers, connects to each server in turn (via the likes of Net::SSH) executes the script and captures (or transfers) the results/output if appropriate.

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
    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: $_"; }
      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?

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (4)
As of 2024-04-19 16:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found