How to provide password to a command that prompts for one in bash?

Take a look at autoexpect (decent tutorial HERE ). It's about as quick-and-dirty as you can get without resorting to trickery.

Take a look at autoexpect (decent tutorial HERE). It's about as quick-and-dirty as you can get without resorting to trickery.

Wonderful - seeing as how my real intent is to be able to do something quick-n-dirty, this is just what I need! – Shakedown Feb 1 at 22:07.

Secure commands will not allow this, and rightly so, I'm afraid - it's a security hole you could drive a truck through. If your command does not allow it using input redirection, or a command-line parameter, or a configuration file, then you're going to have to resort to serious trickery. Some applications will actually open up /dev/tty to ensure you will have a hard time defeating security.

You can get around them by temporarily taking over /dev/tty (creating your own as a pipe, for example) but this requires serious privileges and even it can be defeated.

You're right, I understand why this is a security hole, but I'm already in a secure environment so my primary concern is something quick-n-dirty without having to resort to serious trickery. Thanks for the response! – Shakedown Feb 1 at 22:09.

Programs that prompt for passwords usually set the tty into "raw" mode, and read input directly from the tty. If you spawn the subprocess in a pty you can make that work. That is what Expect does...

Thats really unsecure idea, but: using the passwd command from within a shell script gl bro.

1 I don't think the OP is just asking about passwd. – Jefromi Feb 1 at 0:37.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions