How can I login to a remote server and execute a set of commands then when done logout and continue my script?
Thanks.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
ssh can be used to execute a command, rather than start a remote interactive login shell. For example:
Will log into host and execute the
lscommand.You can use this inside a bash script as normal:
From ssh’s man page, the exit status will be the exit status of the remove command or 255 if an error occurred.