Can you use expect to provide a password?

Can you use expect to provide a password?

Providing the password works, but I don’t end up in the SSH session as I should. It goes back strait to Bash. I would like to have my SSH session and, only when I exit it, to go back to my Bash script. The reason why I am using Bash before Expect is because I have to use a menu. I can choose which unit/device to connect to.

How to send a password with a$ symbol in expect?

Password incorrect. “; exit 1} “*\\$ ” } send_user ” Password is correct ” expect “$ ” { send “ls” } I have verified this works when providing credentials whose passwords don’t contain the dollar sign, but I can’t get it to work with the root account. It always produces the Login failed. Password incorrect timeout error.

Is the root password in expect script a dollar sign?

I have an expect script that I need to login to a remote system and execute commands. This script works with the exception of providing the password to the root account. The root password contains a dollar sign that I cannot seem to get to work. Here is the code

Can you use expect in a bash script?

Mixing Bash and Expect is not a good way to achieve the desired effect. I’d try to use only Expect: This will wait for Enter and then return to (for a moment) the interactive session.

What’s the best way to use expect in Bash?

I’d try to use only Expect: This will wait for Enter and then return to (for a moment) the interactive session. The easiest way is to use sshpass. This is available in Ubuntu / Debian repositories and you don’t have to deal with integrating expect with Bash. The above command can be easily integrated with a Bash script.

How to write a script to provide a password?

After looking for an answer for the question for months, I finally find a really best solution: writing a simple script. Done! instead, as passwords starting with a dash (-) will fail otherwise. The above won’t interpret a string starting with a dash as an option to the send command. Use the helper tool fd0ssh (from hxtools, not pmt).

Is there a way to expect a SSH password?

Done! instead, as passwords starting with a dash (-) will fail otherwise. The above won’t interpret a string starting with a dash as an option to the send command. Use the helper tool fd0ssh (from hxtools, not pmt). It works without having to expect a particular prompt from the ssh program.