Log maintain in Perl


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Log maintain in Perl
# 1  
Old 12-07-2010
Log maintain in Perl

hi ,

While working on perl, have to write a continuous log file which I can monitor. I tried like,

Code:
open (LOG,'>'.$log.'/Report_'.$todaysdate.'.log') or die("Unable to create the log file");

print LOG "\nDate : ".`date`;

But when I ran the script in backend and monitor log, it generates after all script ends and not before that.


can anyone help please

# 2  
Old 12-07-2010
You can create a file object and can use anywhere.

try:

Code:
my $FOBJ = new FileHandle "> $log";
code line 1;
print $FOBJ "log msg 1";
code line 2;
code line3;
print $FOBJ "log msg 2";
code line 4;
code line 5;

You don't need to close the file also.
R0H0N
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Maintain line format using awk

Hello I have a file with the following format: ... text1 num num P # 2014--2-28-22---6 33.76--38.4173---21.9403----0.08-0.00--0.01--0.01--0.46----------0 text1 num num P text 2 num num S text 3 num num P ... (where "-"=space, "spaces" cannot... (4 Replies)
Discussion started by: phaethon
4 Replies

2. Shell Programming and Scripting

Need to maintain in- and output format with awk

Hi All, I have a data file (myfile.txt) as below: - A H C - A HHH F - AAA HH I The importan point is that the width between the columns are not fixed and the column seperator is space. I wish to change the value of 4th column using awk only when $3 = HH. I can... (4 Replies)
Discussion started by: angshuman
4 Replies

3. Shell Programming and Scripting

Maintain health of passwd file

Hello guys I am about to write a script that is based on "The Linux Administration Handbook" The exercise is as follows: Write a shell script to help monitor the health of the /etc/passwd file. Find entries that have UID0 Find entries that have no password (needs /etc/shadow) Find any... (4 Replies)
Discussion started by: Learn4Life
4 Replies

4. Homework & Coursework Questions

Maintain health of passwd file

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: Hello guys I am about to write a script that is based on "The Linux Administration Handbook" The exercise is... (6 Replies)
Discussion started by: Learn4Life
6 Replies

5. Shell Programming and Scripting

awk maintain case query

# Print list of word frequencies { $0 = tolower($0) for (i = 1; i <= NF; i++) counter++ } END { for (word in counter) printf "%s\t%d\n",word, counter } I have this simple awk code from awk user guide to count the frequency of word. Now consider the... (7 Replies)
Discussion started by: ajacobs365
7 Replies

6. UNIX for Dummies Questions & Answers

Just asking - Tips on how to maintain your scripts ..

Hi all, Just writing to ask if any one can advise on what tools to use best for maintaining your scripts ... preferably free/open source and portable if there is one, that is, one that can be placed and run on a USB stick ... At the moment, am having them in directories and files and no... (2 Replies)
Discussion started by: newbie_01
2 Replies

7. UNIX for Dummies Questions & Answers

maintain database script...

Hi there. i'm new user at here I need help for this. I need to write a script that maintains a database of cryptographic checksums. In other words, I need this script to check the files checksum whether the files has been modified or not. But i got no idea where to start. Hope anyone here can... (8 Replies)
Discussion started by: hihihehe
8 Replies

8. UNIX for Dummies Questions & Answers

How to maintain the content of array in any directory I go?

Hi all, I have this scenario where:- The file that I want to save its name into array df is my.08120323.trx which is located in the dir as below: $ pwd /u01/abc/def/SRC_datafiles $ ls *trx my.08120323.trx $ df=*"trx" ##keeping the filename... (1 Reply)
Discussion started by: luna_soleil
1 Replies

9. Shell Programming and Scripting

How to maintain wildcard array variable

Hi all, I have this scenario where:- The file that I want to save its name into array df is my.08120323.trx which is located in the dir as below: $ pwd /u01/abc/def/SRC_datafiles $ ls *trx my.08120323.trx $ df=*"trx" ##keeping the filename my.08120323.trx into df $... (2 Replies)
Discussion started by: luna_soleil
2 Replies

10. Shell Programming and Scripting

Maintain 30 days data

Hi Folks, I have a log file that keeps the information pn the date and time a specific transaction is firedup. I found that the log file keeps growing and I intend to limit the entry to the log file to 30 days. Log file name is transaction.log, here is the content: 120802_23:47:37 ... (3 Replies)
Discussion started by: odogbolu98
3 Replies
Login or Register to Ask a Question