in reply to run a perl script on a unix machine from a win machine

system("plink $server");
That starts a new interactive shell on the remote system and it just keeps waiting for you to type some command at the console. What you probably want is:
system "plink $server $cmd";
BTW, check also Net::SSH2.

Replies are listed 'Best First'.
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
    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.

      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.
      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.