ssh, file read, etc. Help please!
I want to be able to write a script that manages a system remotely. this is what i have and i can't seem to figure out the problem, so any pointers, suggestions, comments, possible fixes would be greatly appreciated. =)
---main--- #!/bin/bash while read cmd; do ssh 10.10.10.10 $cmd done < command.file --command.file--- echo "hello" echo "this is a test" . . etc... i have it set such that there's a trusted host relationship b/w the host and client so there's no password prompt. what seems to happen is that while loop in the main program only executes the first command in the command file. and i have no clue why. help... pleaaaaaaaaase? |
First, I would suggest using ssh only once. In other words, put your management script on the remote machine, then use ssh to execute that script. You can get the script there by using ftp, scp, or whatever. Then all you would do is: ssh 10.10.10.10 management_script
If that's not an option and you must execute the commands like the script you have above, then i would change it to something like this: Code:
#!/bin/bash Unfortunately, I don't have an environment to test this on (I only have one machine). So I can't say with 100% certainty it would work. |
All times are GMT -5. The time now is 09:45 AM. |