0

I have a basic shell script like this;

#!/usr/bin/bash
echo "Openning ssh connection to remote host "$2" for "$1" user and finding the archive directory "$3""
ssh "$1"@"$2" find "$3"

I have another perl script named with Archive.pl in that script we are connecting remote server with Telnet connection. I want to call my script inside this Perl script to use other modules of Perl script. I'm trying that command but it doesn't work.

system("Connector.sh",$arg1,$arg2,$arg3);

Any ideas to do that ?

7
  • Are you sure of the path?? Commented Mar 19, 2014 at 11:50
  • Perl and bash script is at the same path actually Commented Mar 19, 2014 at 11:51
  • I guess you need to mention - ./Connector.sh Commented Mar 19, 2014 at 11:52
  • I need to do it inside the Perl script. I'm not trying to work on the console "sh script.sh". Because in Perl script there are other modules which i wanted to work on. Commented Mar 19, 2014 at 11:55
  • Is it really valid to nest quotes like that? echo "Opening ... "$2" for "$1" ...."$3""? Commented Mar 19, 2014 at 12:15

1 Answer 1

1

You can skip the shell script, and just put this in your Perl script.

print qq(Opening ssh connection to remote host "$arg2" for "$arg1" user and finding the archive directory "$arg3");
system("ssh", "$arg1\@$arg2", "find", $arg3)
Sign up to request clarification or add additional context in comments.

17 Comments

ssh: picroot: temporary name resolution failure. I'm getting that error
What is picroot? Does the ssh connection work outside your Perl script?
picroot is username. Yes i can easily connect via console or my bash script.
See my edit; I forgot to switch to the correct variables for the call to system. Does that help?
You forgot to escape the @ sign, so @$arg2 was interpolated to the empty string, which made the ssh fail. Since you did not use warnings, you were not warned about this critical failure. Lesson is: always, always, always use use strict; use warnings;.
|

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.