tail copy of a file to remote location


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting tail copy of a file to remote location
# 1  
Old 05-19-2009
PHP tail copy of a file to remote location

Hello,

I have a solaris box and a windows server. The windows server runs cygwin for ssh service. I have an audit log in solaris box. When ever new records are added to the log file, this delta has to be trasported to a remote file in windows. I can do a ssh once in a while, but want the transfer to be real time. tail -f gets me this kind of output. But I don't know how to scp or sftp this output to a remote file. I am looking for a script that can do this.
I have set up a password less authentication between these two servers using public keys.

Please help me out.

Thank You

Last edited by unori; 05-19-2009 at 05:58 PM..
# 2  
Old 05-20-2009
Reply to your plroblem

Just use rsync:

Using Rsync and SSH
# 3  
Old 05-20-2009
(Untested)
Code:
tail -f file | ssh wherever.com "cat >> file"

# 4  
Old 05-20-2009
I didn't know this was going to a mod first, I answered the question twice, so pick one and delete it.

Yay! I got my first 5 point infraction!

Last edited by ascrivner; 05-21-2009 at 05:20 AM..
# 5  
Old 05-21-2009
Quote:
Originally Posted by cfajohnson
(Untested)
Code:
tail -f file | ssh wherever.com "cat >> file"

Thanks. I will try this.
# 6  
Old 05-21-2009
Quote:
Originally Posted by unori
Thanks. I will try this.
It worked thanks. But when the file is rotated (The file gets deleted/renamed when it exceeds a certain size and another file with the same name gets created), the functionality is broken. It is no longer watching the new file. Is there any way of watching the new file, with out running the script again? Thanks.

Last edited by unori; 05-21-2009 at 04:32 PM.. Reason: sentence correction
# 7  
Old 05-21-2009

With GNU tail, use
Code:
tail --follow=name file

With BSD tail,
Code:
tail -F file

.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Find and Copy file of specific location

Dear All, I need to transfer all files present in one location to another but those files should be of specific extension like. Find and copy all files of extension .xls, .pdf, .txt from location usr/tmp to location /per/Treat (6 Replies)
Discussion started by: yadavricky
6 Replies

2. Shell Programming and Scripting

Copy file from UNIX to shared location

Hi All, I want to transfer file from UNIX to shared locataion . Shared location doesn't resides on my system. Can somebody tell me is there any way i can transfer file from UNIX to shared location without using any tool WINSCP. Thanks, Amit (1 Reply)
Discussion started by: Amit786
1 Replies

3. Shell Programming and Scripting

How to copy a file from one location to another location?

I have file file1.txt in location 'loc1'. Now i want a copy of this file in location 'loc2' with a new file called test.txt. Please help me how to do this in shell script. (1 Reply)
Discussion started by: vel4ever
1 Replies

4. Shell Programming and Scripting

Sftp- file not present in the remote location

I'm able to connect to the remote server (server_name). But when i'm transferring the files, its getting transferred. But the file is not there in the remote location. I tried with a zero byte and 5 byte file sftp6 -P <port-no> --password=file:///<file having the pwd>... (1 Reply)
Discussion started by: help_scr_seeker
1 Replies

5. Solaris

File copying to Remote Location

Hi Team, I am copying larger set of files from local to remote location through FTP. Remote location is processing the file before copying the full set of file(less than 100%). Remote location file process should be started post 100% file completion(full copied) and need to display some... (1 Reply)
Discussion started by: boopathi
1 Replies

6. Shell Programming and Scripting

copy tail output to an external file in perl

The below code works to tail client.log file. but I want to copy the output into an external file /home/tail.txt Can anyone please help. #!/opt/bin/perl -w open my $pipe, "-|", "/usr/bin/tail", "/var/log/client.log" or die "could not start tail on /var/log/client.log : $!"; print while... (2 Replies)
Discussion started by: sureshcisco
2 Replies

7. Shell Programming and Scripting

Shell Script for Copy files from one location to another location

Create a script that copies files from one specified directory to another specified directory, in the order they were created in the original directory between specified times. Copy the files at a specified interval. (2 Replies)
Discussion started by: allways4u21
2 Replies

8. Shell Programming and Scripting

Bash copy file contents into an existing file at a specific location

Hi all I need to copy the entire contents of one file into an existing file at a specific location. I know the exact line number where I need to put it. It appears I would use either sed or awk to do this, but I have been unsuccessful so far: File A line 1 line 2 line 3 line 4 ... (6 Replies)
Discussion started by: gshepherd7
6 Replies

9. UNIX for Advanced & Expert Users

copy files from one location to similar location

I need help in forming a script to copy files from one location which has a sub directory structure to another location with similar sub directory structure, say location 1, /home/rick/tmp_files/1-12/00-25/ here 1-12 are the number of sub directories under tmp_files and 00-25 are sub... (1 Reply)
Discussion started by: pharos467
1 Replies

10. UNIX for Dummies Questions & Answers

excutable script to copy a file to a different location.

Hi, I'm try to create an executable file to copy a file to a different location. Help plz. Thanx. (4 Replies)
Discussion started by: nazehcalil
4 Replies
Login or Register to Ask a Question