How to use expect and Bash script together in Same script
Linux - ServerThis forum is for the discussion of Linux Software used in a server related context.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
How to use expect and Bash script together in Same script
Hi,
I want to use expect and Bash script in same script. How can i use that?
Below is the example what i need actually
-->I want to login server1 (For that i want to use expect script to login machine)
-->Next i wanted to some testing using Bash command
-->Exit from Server1 Machine
I am using ssh only. As per your instruction i will use public-key authentication. May i have steps or document to create password less auth using ssh.
to set it up you need to run "ssh-keygen" on the local machine and then distribute the resulting public key to each of the target machines using "ssh-copy-id server1" for each serverN.
Once you have done the above you'll need to run ssh-add once each session to enter your passphrase. After doing so, for the rest of the session you can ssh to each serverN without using a password. The ssh-add command will connect to the local ssh-agent which will have been automatically started by most modern desktops. Otherwise you can start it manually with:
Code:
eval `ssh-agent`
before running ssh-add.
There are many tutorials online. Post back with questions if you get stuck.
I am using ssh only. As per your instruction i will use public-key authentication. May i have steps or document to create password less auth using ssh.
Thanks
follow the links in my signatures for HOWTO guides on setting up your ssh keys.
./nn.sh: line 5: spawn: command not found
couldn't read file "password:": no such file or directory
./nn.sh: line 7: send: command not found
couldn't read file "$": no such file or directory
./nn.sh: line 9: send: command not found
./nn.sh: line 10: send: command not found
./nn.sh: line 12: unexpected EOF while looking for matching `"'
./nn.sh: line 13: syntax error: unexpected end of file
what do i have to do ?
how can solve this problem?
i have the same problem i want in bash just get a parameter then in expect connect to second server and echo a file with that parameter when i run just expect work correctly
./nn.sh: line 5: spawn: command not found
couldn't read file "password:": no such file or directory
./nn.sh: line 7: send: command not found
couldn't read file "$": no such file or directory
./nn.sh: line 9: send: command not found
./nn.sh: line 10: send: command not found
./nn.sh: line 12: unexpected EOF while looking for matching `"'
./nn.sh: line 13: syntax error: unexpected end of file
what do i have to do ? how can solve this problem?
Best regards
While this is on topic, it's best not to reopen old threads...visibility is MUCH better if you open your own thread for your own question. Also, please see the "Question Guidelines" link in my posting signature.
Again, though, as was said to sagar666 when he opened this thread, you *REALLY* shouldn't do this. It is NEVER, EVER a good idea to hard code a user ID and password into a script...from a security standpoint, it makes the remote machine vulnerable, and you can script much more easily if you do a key swap (as described in this thread), to accomplish what you're after. Once you do the keyswap, read the man page on the ssh command, and pay particular attention to the "-c" flag, which will let you run your command.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.