0

I'm writing a Perl script that is to be run on a PC networked with a computer running Linux. The script must give input to, and receive results from, a set of shell scripts on the Linux machine. I'm able to copy the input files from the PC and even invoke a Perl script on the Linux machine, but when that script attempts to run the .sh files via:

 system("./shell_script.sh");

It prints the following error:

 '.' is not recognized as an internal or external command, operable program or batch file.

Which I take to mean it's trying to execute the .sh files under Windows. So is there any way to get the PC to tell the Linux box, "hey, buddy, run this yourself"?

Thank you.

2
  • A small bit of sample code to give some context around the system call may be useful. Commented Aug 31, 2009 at 21:14
  • Good idea, just a sec... Commented Aug 31, 2009 at 21:23

2 Answers 2

6

You can use Net::SSH::Perl to run the commands/scripts on remote machine:

use warnings;
use strict;

use Net::SSH::Perl;

my $command = "command";
my $host = "host";
my $user = "username";
my $pass = "password";

my $ssh = Net::SSH::Perl->new( $host );
$ssh->login( $username, $pass );
my($stdout, $stderr, $exit) = $ssh->cmd( $command );

print $stdout;
Sign up to request clarification or add additional context in comments.

Comments

5

I think you want to use something like Net::SSH or Expect to login into the Linux machine and run the shell script. The system() runs on the local machine; it's not a way to send commands to a remote machine.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.