Sponsored Content
Operating Systems Solaris Problem in appending the correct log Post 302319732 by filmjbrandon on Tuesday 26th of May 2009 05:13:10 AM
Old 05-26-2009
Considering that you are passing a parameter to the begin function and using it as a key... if you pass anything that's an invalid key, then the begin function will break, which will break the rest of the script.

Code:
sub begin{
my($parm)=@_;
$log_start_time{$parm}=localtime(time());
$log_begin{$parm}=time();
$log_msg{$parm}="** $parm Process **";
}

It would probably be easier/more robust to use objects to accomplish this task.

Code:
$dnbLog = new TrxLogObj("DNB Process");
$otherLog = new TrxLogObj("Other Process");

$dnbLog->start();
$dnbLog->log("Something interesting happened here");

$otherLog->start();
# Do your process stuff here...
$otherLog->stop();

$dnbLog->stop();

This way each object is it's own logging session, with it's own instance variables, one of which is a text string indicating the name of the session, the others are the message array, the filehandle and start and stop times.

This allows you great freedom to start and stop multiple logging sessions, and insulates you from having to use specific keys in your scripts to reference those sessions.

It's relatively trivial to convert your code to the object format, but also might be easier to use one of the many pre-existing Log classes and adapt for your use, just search CPAN.


-FilmJ
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

will reinstalling correct my problem??

about 2 months ago i installed mandrake linux 8.0 however due to my current internet setup (dial up upsteam, and cable downstream) i was never able to get it configured properly so i gave up untill i could change to an all cable isp...well that day is tomorrow!!! what i would like to know is... (1 Reply)
Discussion started by: justchillin
1 Replies

2. Shell Programming and Scripting

AWK scripting problem - appending values

ABC:10:A1:ABCA110 ABC:10:A1:ABCA110 ABC:20:A1:ABCA120 DEF:20:D1:DEFD120 GHI:30:G1:GHIG130 GHI:40:G1:GHIG140 JKL:30:J1:JKLJ130 MNO:10:M1:MNOM110 What I'm trying to do is look through a file that consists of four columns (as above). As you can see there are duplicates in the file, i.e.... (2 Replies)
Discussion started by: rowntree
2 Replies

3. Shell Programming and Scripting

Can someone kindly help with appending problem!!!

Hi guys,i urgently need help in this problem,i need to append one sentence to another line when it meet a certain word. For example: root: root time_last_login = 1191232080 root tty_last_login = /dev/vty0 root host_last_login = rep1nim root unsuccessful_login_count = 0 root... (10 Replies)
Discussion started by: cyberray
10 Replies

4. UNIX for Advanced & Expert Users

Correct format in a log file

I'm trying to read the output of a .sql script (simple insert and commit oracle pl/slq script) to a log file using a shell script. My problem is I end up with a log file that looks like this: sd12@phenix97:/detain/sd12/logs > cat 20071205_detain_20071206.log 12320496 rows created. Commit... (11 Replies)
Discussion started by: sd12
11 Replies

5. Programming

Problem in getting the correct number from the string.

I have string named texts which consist of section label “BOOK-SEC-“. Section starts from 1 to n, where n is a number. For this example conside the value of n is 9. That is, the string variable looks like “BOOK-SEC-1... (2 Replies)
Discussion started by: SamRoj
2 Replies

6. Shell Programming and Scripting

Problem with appending a file!

Hi All, I have a script which i use in office. This script is used to log the work in users name. For that in the script itself I have added that the infomration should append to the logfile everytime the script is run. LOGFILE=/data/log/request1.txt All these days it was... (3 Replies)
Discussion started by: smarty86
3 Replies

7. Solaris

Help with finding correct log files

Lets say i have files like the following format :- R0001.log R0002.log ... ... R00011.log upto R000n.log, there are also a lot of text files with different names now how can i find these files with in a range, i can do "ls R000*.log" and it will show me all the R000*.log files but what... (2 Replies)
Discussion started by: oopsalion
2 Replies

8. UNIX for Dummies Questions & Answers

Appending timestamp problem

Hi, I am trying to insert a timestamp after all the file names in a folder,after the timestamp is created in the filename the file size is becoming zero bytes. please tell me where I am doing it wrong. I have declared the variable in starting of my script. timestamp=`date... (1 Reply)
Discussion started by: shruthidwh
1 Replies

9. Shell Programming and Scripting

sed appending problem

i have a number of java files containing eg: --------------myfile.java-------------- package zip.fun.myfiles; import java.* import something..; import sdfdfdsa; ... ... -------------------------------------------- Now I need to append / insert a line as follows: ... (10 Replies)
Discussion started by: linuxadmin
10 Replies

10. Shell Programming and Scripting

Appending 2 text files - Problem in windows

Hello, I have text files to append and am able to do with cat. cat file1 file2 >file3 and file3 works fine in UNIX (checked with vi and it looks fine) but when i open the same file in windows I see 2nd file appended as a single-line. In other words, all the lines of 2nd file appended to... (2 Replies)
Discussion started by: magnus29
2 Replies
XmTransferSetParameters(library call)									     XmTransferSetParameters(library call)

NAME
XmTransferSetParameters -- A toolkit function that establishes parameters to be passed by the next call to XmTransferValue SYNOPSIS
#include <Xm/Transfer.h> void XmTransferSetParameters( XtPointer transfer_id, XtPointer parm, int parm_fmt, unsigned long parm_length, Atom parm_type); DESCRIPTION
XmTransferSetParameters establishes a parameter definition. Your application calls XmTransferSetParameters just before calling XmTransfer- Value, and only if XmTransferValue needs to transfer a value containing a parameter. transfer_id Specifies a unique indentifier for the data transfer operation. The value must be the same as the value of the transfer_id mem- ber of the XmDestinationCallbackStruct passed to the XmNdestinationCallback procedure. parm Specifies parameters to be passed to the conversion routine (and the XmNconvertCallback procedures, if any) of the widget that owns the selection. The type and length of parameters are target-specific. If the target takes no parameters, the value is NULL. parm_fmt Specifies whether the data in parm should be viewed as a list of 8-bit, 16-bit, or 32-bit quantities. Possible values are 0 (when parm is NULL), 8, 16, and 32. parm_length Specifies the number of elements of data in parm, where each element has the number of bits specified by parm_fmt. When parm is NULL, the value is 0. parm_type Specifies the type of parm. RELATED
XmTransferSendRequest(3), XmTransferStartRequest(3), and XmTransferValue(3). XmTransferSetParameters(library call)
All times are GMT -4. The time now is 04:09 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy