1

I have a perl script which calls a command which before executing asks for confirmation. How do I handle this in Perl?

For example let say in my perl script I am doing the following

`ssh myServer`;

Before connecting I get a prompt asking to proceed or not. I have to provide yes as my next command. How can I achieve this? Any code snippet would be useful.

2 Answers 2

1

If you are looking at interactive you can use Expect on the CPAN...

"Expect is a generic tool for talking to processes that normally require
user interaction. This might be running an ftp client to grab a file,
telnetting to a router to grab statistics or reset an interface. Or, as in the
case of a place I recently administered, to start up a secure webserver without
having to be physically at the machine to enter the super secret password."

However, there are other (better) methods to automate SSH login. I.e. by using ssh-keygen

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

1 Comment

This is the best method IMO if you control both hosts.
0

From Net::SSH :

interactive Set to a true value if you're using Net::SSH::Perl interactively. This is used in determining whether or not to display password prompts, for example. It's basically the inverse of the BatchMode parameter in ssh configuration.

Defaults to false.

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.