copy tail output to an external file in perl


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting copy tail output to an external file in perl
# 1  
Old 08-04-2010
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.

Code:
#!/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 <$pipe>;

# 2  
Old 08-04-2010
Code:
#!/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 : $!";
open (FW,">","/home/tail.txt");
print FW while <$pipe>;
close(FW);

# 3  
Old 08-04-2010
Pravin27....It works great Buddy! Thanks a lot.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Redirect output to memory instead of an external file

I use the following as an example. I find myself always doing this and I believe my scripts would run much faster if I put the sed results into a place in memory rather than writing to files. Again, its not about sed, its about redirecting to a place in memory rather than an external file. ... (5 Replies)
Discussion started by: popeye
5 Replies

2. Shell Programming and Scripting

I want to copy all files of a said type on my external hard drive

My code is this, what I'm trying to accomplish is to make a list of all pdf documents in my computer and then copy all of those documents to my external hard drive in a directory mkdir /Volumes/Hardrive-1/allpdf echo "File Locations" > /Volumes/Hardrive-1/allpdf/FileLocations.txt mdfind pdf... (2 Replies)
Discussion started by: darpness
2 Replies

3. Shell Programming and Scripting

Perl error while using File::Tail

Hi, Can someone help with this PERL code; I am getting this error while running below code: And this is the code: use File::Tail; $file=File::Tail->new("/some/log/file"); while (defined($line=$file->read)) { print "$line"; } I don't usually use PERL therefore I am not... (1 Reply)
Discussion started by: INHF
1 Replies

4. Shell Programming and Scripting

File Copy Perl

Hi Could you please help me on this I have folder called D:\Data in which we have 20 files coming daily and needed all 20 files to copy into D:\Target ,as i am new to PERL, i did nt know how to use this I googled sme of the code and done the copy script,it is throwing error like we do... (1 Reply)
Discussion started by: vaas
1 Replies

5. Shell Programming and Scripting

how to tail a file in perl

Can any one please help why does tail -f does not work in the below code: Thanks in advance. #!/usr/bin/perl -w my $path = "/home/cs/logs/"; my $log = "log.txt"; `cd $path`; `tail -f $log`; (3 Replies)
Discussion started by: sureshcisco
3 Replies

6. Shell Programming and Scripting

how to read tail -F command output in perl

Hi All, How I will read the output of the tail -F command in perl. I have text file with below contains file1.txt 1 2 3 4 $running=1; sub openLog($) { (my $log) = @_; (1 Reply)
Discussion started by: pravin27
1 Replies

7. Shell Programming and Scripting

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... (7 Replies)
Discussion started by: unori
7 Replies

8. HP-UX

Can I copy a Unix file to a external memory stick?

I'm doing server maintainence to a HP UX server and I have 2 files that someone need for an unknown reason. I was wondering If I can put this files on a memory stick, or is there someother way I have to copy it for them? (3 Replies)
Discussion started by: MarcKim
3 Replies

9. UNIX for Dummies Questions & Answers

I want to copy the text output from a 'nohup.out' file.

Hello, I have a nohup.out file that, when executed, outputs a spreadsheet file with four-to-seven columns of number. I want to copy this output (in its entirety), so that I could then paste it on excel@ , or Notepad@. Please help, thanks. (3 Replies)
Discussion started by: Iamthe great
3 Replies

10. UNIX for Dummies Questions & Answers

Output from tail to a user

Hi all I've read through a few of these lists but can't find a right combination of answers (I can create VPN's but can't send an email!) Ok - I'm using taper as backup software which generates a log file called taper_log I want the last eight lines of this log file to be sent to a specified... (3 Replies)
Discussion started by: ifan
3 Replies
Login or Register to Ask a Question