Results 1 to 3 of 3
I need to output of the script to the remote server via redirect. I created a simple script for your reference.
#!/bin/bash
W=`/usr/bin/w`
FREE=`/usr/bin/free`
echo "$W
$FREE"
I need the ...
- 05-19-2009 #1Linux Newbie
- Join Date
- Mar 2006
- Posts
- 101
redirect output to remote server via ssh
I need to output of the script to the remote server via redirect. I created a simple script for your reference.
I need the output of the script to be transferred to the remote server (192.168.0.1) and do it via ssh or scp. I tried the following:#!/bin/bash
W=`/usr/bin/w`
FREE=`/usr/bin/free`
echo "$W
$FREE"
I got error when I tried the command above.ssh -i /home/foo/test root@192.168.0.1 "/path/scrpt.sh"
Any recommendation.
TIA
- 05-19-2009 #2Just Joined!
- Join Date
- May 2009
- Posts
- 4
Hi,
what you do is this.
1. you use scp
scp /path/script.sh root@192.168.0.1:foo/test/
This will copy the script to the directory /root/foo/test on the remote server, if that's your objective.
If you want the output of that script to be sent, depending on what the script does, you can do something like this
`scp $output root@192.168.0.1:foo/test/
where $output is what is produced from the script.
Before that generate a pair of keys, store the public one on the remote machine so that you are not asked for password.
- 05-19-2009 #3Linux Newbie
- Join Date
- Mar 2009
- Posts
- 228
The command you posted tries to run the script on the remote host. If you want to direct the output to the remote host when you execute the script on the local host the command would look something like:
I left out the ssh -i option so it'll prompt you for the password. Try getting this to work first and then add the use of public/private keys.Code:/path/script.sh 2>&1 | ssh root@192.168.0.1 "cat > /path/script.log"


Reply With Quote