Monday, December 16, 2013

Log redirection

www.unixbabuforum.inI have a ksh named ABC.ksh in which i define the log file using these syntax: 
export SCRIPT="${0##*/}" 
export LOGFILE="${HOME}/log/${SCRIPT%.*}.log" 
According with this the logfile name should be ABC.log 
I ran the program in another box under a user ID having sh environment. 
When I ran the program the log file name is .prc122966.log 
I believe that the SCRIPT variable is overitten somehow by the sh environment. 
When I ran it in ksh everything is working fine. 

www.unixbabuforum.inmay be it is not POSIX compliant or you env variable is overwwiting it. 

why dont you just use 

export SCRIPT=$( echo $0 | cut -d. -f1) 
export LOGFILE="${HOME}/$SCRIPT.log" 

www.unixbabuforum.inAt least in Solaris, the Bourne shell does not accept an export and an 
assignment of a variable in a single statement, whereas the Korn shell 
does. You may have to break out the export [variablename] as a separate 
statement after the variable is assigned the value you want.

0 comments:

Post a Comment

 
Design by BABU | Dedicated to grandfather | welcome to BABU-UNIX-FORUM