Remote server file output redirection


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Remote server file output redirection
# 1  
Old 02-02-2009
Remote server file output redirection

Hi,

I want ssh to the remote server and then execute ls and redirect the output to the file in remote server itself

like

ssh root@$server `ls /var/log/users.txt > root@$server:/home/users.txt`

Can you please let me know the correct syntax for it.

Thanks in advance
# 2  
Old 02-02-2009
Correct syntax would be
Code:
$ ssh root@${server} 'ls /var/log/users.txt > /home/users.txt'

Any redirections you specify for the remote command will be executed on the remote server, thus no need to add another root@$server
# 3  
Old 02-02-2009
Hi,

Thanks. I was missing quote.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Command output redirection to file issues

Hi, I have a peculiar issue w.r.t redirecting the command output to a file when using loop. I am redirecting command output to same file in a series of if condition statements, but if one block of if condition statement writes the log to the file , the subsequent block of if condition... (7 Replies)
Discussion started by: ananan
7 Replies

2. Shell Programming and Scripting

How to Append the output of a script running in remote server to a file in local server?

Hi guys, So i am in server1 and i have to login to server 2, 3,4 and run some script there(logging script) and output its result. What i am doing is running the script in server2 and outputting it to a file in server 2 and then Scp'ing the file to server1. Similarly i am doing this for other... (5 Replies)
Discussion started by: srkmish
5 Replies

3. Shell Programming and Scripting

output redirection to existing file question

So I have a existing file that I used the uniq command on and I need to save the output to the same file without changing the file name. I have tried $ uniq filename > filename then when I cat the file it then becomes blank like there is nothing inside. any help would be much appreciated... (0 Replies)
Discussion started by: drew211
0 Replies

4. Shell Programming and Scripting

Remote server's output

Hi All, Can anybody help me, i have 50 servers within a network. For checking the HDD utilization using df -k, Right now i am logging into each server daily and then noting the output. I want that i should be able to run the command in all servers while sitting in single server and getting... (1 Reply)
Discussion started by: varunksharma87
1 Replies

5. Shell Programming and Scripting

awk output redirection to file

I have a system stat command running which generates data after 5 sec or so. I pass this data to awk and do some calculation to present the data differently. Once done now I want to pass this data to file as and when generated but doesn't work..unless the first command completes successfully.... (6 Replies)
Discussion started by: learnscript
6 Replies

6. UNIX for Dummies Questions & Answers

Output file redirection

Suppose I have a file named a When I write cat a>a The following error message is displayed cat: a: input file is output file and my file a is truncated to zero size. Also the exit status of the last command is 1 Can someone tell me what actually happens when I do so? (1 Reply)
Discussion started by: aagajaba
1 Replies

7. UNIX for Dummies Questions & Answers

Redirection of output to a log file

Apologies for the trivial nature of this question but I cannot seem to get a simple re direct to a log file to work Step 1 touch log.txt at -f batch.sh now >> log.txt I am trying to get the batch.sh contents into the log file Manny Thanks (8 Replies)
Discussion started by: JohnCrump
8 Replies

8. Shell Programming and Scripting

formatting output from a remote server

Hi Unix Gurus, I have the following output from a remote sftp server sftp> cd outgoing sftp> ls . .. archive x001_ameint_BP020F0025_00306_001.zip x001_ameint_DV010F0060_00306_001.zip x001_ameint_DV010F0065_00306_001.zip x001_ameint_DV010F0065_00306_002.zip... (2 Replies)
Discussion started by: ramky79
2 Replies

9. UNIX for Dummies Questions & Answers

Mailing the output which is there in remote server

Hi all, I have a script which logs in to the remote server with FTP and with the user id/password and list the files in the path of remote server where thefiles resid.i need to email this output(i.e wether the files are present on not under the path) to my email id. Can u please let me know as... (2 Replies)
Discussion started by: OSD
2 Replies

10. Shell Programming and Scripting

Mailing the output which is there in remote server

Hi all, I have a script which logs in to the remote server with FTP and with the user id/password and list the files in the path of remote server where thefiles resid.i need to email this output(i.e wether the files are present on not under the path) to my email id. Can u please let me know as... (2 Replies)
Discussion started by: OSD
2 Replies
Login or Register to Ask a Question