1

I have a perl script where I need to connect to another machine using ssh and there run another perl script. I tried using this line:

system("ssh $admin_server 'perl /Perl/scripts/capture_server_restarts_gse.pl $month $date'");

But everytime the script gets to that line, I get the prompt for the remote machine and the script doesn't run.

How can I fix this so the script runs automatically on the other machine without showing the prompt.

Note: I don't need the password and user to connect to the remote machine we already solved that.

1
  • Try basic debugging first, like print instead of system, or 'touch /tmp/this.is.me.debugging' instead of the perl script. Also try giving the remote perl interpreter some switches like -c and -w, anything to get some debugging out of it. How about making ssh more verbose? Commented Jan 14, 2013 at 22:56

2 Answers 2

3

Why not copy your public key onto the other machine ? That way you'll be pre-authorised.

Here are the instructions on how to do this using ssh-keygen

Otherwise you have to feed ssh with your password, and that's tricky since ssh normally takes input from a tty and you have to configure your script with the password.

Sign up to request clarification or add additional context in comments.

1 Comment

no need for that, I already change all the permissions and it is not asking me about the password
0

The SSH server may be configured to run always some custom shell instead of the command passed from the client.

Try just running some simple command from the command line, i.e.:

  ssh server ls

A less likely possibility is that the perl variables interpolated into the system argument could contain some shell metacharacters requiring better escaping. For instance, a semicolon inside $admin_server.

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.