getting return code from command with piped input
I have the following line in a bash script:
echo password > ssh root@domain command I want to get the status (return code) from the SSH command, NOT the ECHO command. The SSH connects (it gives me a "success" message). The command is not working for some reason and I want to determine the reason. I have several commands, (each on a separate SSH line in the script) and want to be sure they all work, before concatenating them into one <compound-command> in a single script line. I own multiple (about 35) Linux machines and need to manage them remotely. They all have the same id (root) & password for management. I am building an .ssh directory with my pubkey in the auhorized_list to do this more effectively in the future. |
I think your command line is wrong, namely the ">" is used to write to a file, not to pipe commands together.
Try switching to "|" (pipe). The password you're echoing is for the ssh authentication on the remote host? |
I tried switching to "|" and that while it appeared to make the ssh connection, the comand following it was not recognized. The command is "mkdir" with all the necessary parameters.
Yes, I am passing the password via echo (hence the >), to ssh, so I don't have to keep retyping it. I have been told that doing: echo "something" > pgm will act as if I were typing it from stdin. |
Let me tell you that you're doing it wrong ;)
Instead of using a password login with ssh switch to a password-less authentication. There are tons of tutorials on how to do it on the web. This is just one of the many out there. |
Quote:
And yes, if I had KNOWN I would need to do this remote access, I would have installed the keys before I put the machines to use. |
for that to work I believe you have to write the script with expect
Quote:
|
Quote:
|
All times are GMT -5. The time now is 06:42 AM. |