Scripting issue: Reading a file from a remote server
I have an situation where I want to read a file into my script that lie on a remote server. I have ssh-keys set up just don't know how to do this.
Thanks if you respond. |
Quote:
There are MANY bash scripting tutorials you can find on Google, if you're just starting out. |
I tried to ssh to the remote server and cat the file, but when i turned on the trace (set -x) it would sit at the $ prompt of the remote server and the rest of the script did not run.
|
Quote:
http://tldp.org/LDP/abs/html/ Something to try is Code:
variable = `ssh <user>@<host> "<command string goes here>"` |
You can set up SMB shares and use "smbmount" to mount the share across the network. That would let you easily read a file on another server.
Or you can look into using the "rcp" command. |
I had a project where I wanted to run the same script on multiple servers from a single point. This became a small application that I am not at liberty to share, but at the heart of it was the following command:
cat remote_script | sshpass -p`echo $PASSWORD` ssh root@$LIST bash So remote_script would be the script I wanted to run. The catch 22 was the script had to use Java style carriage returns in the script and end with an exit command. Example Code:
#!/bin/bash Code:
hostname ;\ |
TB0ne's ssh string was what i was looking for. What had me hung up was that there's no colon after the ip address.
Thanks all. |
I cannot do shares by the way they are forbidden for security.
|
All times are GMT -5. The time now is 05:22 PM. |