views:

240

answers:

2

I currently have a script that ssh's into another server and runs a command. When the ssh command runs though in prompts if I would like to connect (yes/no) and for the password. Is there a way that when the ssh call is made that I could automatically supply the input for the prompt?

Also, I do realize that using a public key with the ssh command would resolve this issue, but I do not have permission to create a public key.

A: 

can you download and install external tools? if you can try, try sshpass. I have not tried, but you can give it a go.

ghostdog74
+3  A: 

Don Libes created Expect exactly so you could program tools that need to interact with prompts. I've even used it with modems! It's a very old tool but very effective, and it deserves to be more widely known.

The only downside is that it uses Tcl, which is not my favorite programming language. But to learn enough Tcl to make simple expect scripts won't take you more than an hour. And Expect is really the perfect tool for the job.

Norman Ramsey
Many languages have ports of Expect, python in particular comes to mind with pexpect
prestomation
While it may not be everyone's favorite language, it is perfectly suited for this type of job. Use the right tool for the job, and in this case expect is generally superior to just about any other tool. It's very mature, very robust, very stable.
Bryan Oakley
@Bryan: right on!
Norman Ramsey