how to create a logfile to track the below script output


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting how to create a logfile to track the below script output
# 1  
Old 03-17-2010
how to create a logfile to track the below script output

Hi Dudes,

Can you please suggest me how to create a logfile to track the below script output ? Thanks


#!/bin/ksh
# backup the "std" I/P file descriptor
exec 5<&0
#echo "Proceed ?"
while read config_line; do
# backup the I/P file descriptor of "while" block
exec 6<&0
# restore the "std" I/P file descriptor
exec 0<&5
script_type=`print $config_line | awk -F" " '{print $2}'`
script_name=`print $config_line | awk -F" " '{print $3}'`
script_path=`print $config_line | awk -F" " '{print $4}'`
#echo "script_type = ${script_type}"
#echo "script_name = ${script_name}"
#echo "script_path = ${script_path}"
if [[ ! -x ${script_path}/${script_name} ]]; then
print "Either there is NO such FIle / Path or Execute permission is not set for ${script_name}."
exit 1;
fi
cd $script_path;
print "Started executing the script, ${script_name} ..."
if [[ ${script_type} = 's' ]] || [[ ${script_type} = 'S' ]]; then
./${script_name};
retval = $?;
elif [[ ${script_type} = 'r' ]] || [[ ${script_type} = 'R' ]]; then
run_script.ksh ${script_name};
retval = $?;
fi

if [[ ${retval} -ne 0 ]]; then
print "${script_name} script is Failed."
else
print "${script_name} script is successfully completed."
fi
# restore the I/P file descriptor of "while" block & close the fd of 51
exec 0<&6 6<&-
done < config.txt
Image
# 2  
Old 03-17-2010
Have you tried simply redirecting? Try this as the last line:

Code:
done < config.txt > config.out

# 3  
Old 03-17-2010
Try this,

Code:
sh script.sh 2&>log_file

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Need a script to create specialized output file

I need a script to process the (space-separate) values for each line as seen in the below input file and then output the data into an output file as follows. We have been unable to create this using typical bash scripting and cold not find anything out on the internet similar to what we are trying... (3 Replies)
Discussion started by: ddirc
3 Replies

2. Shell Programming and Scripting

ksh and Oracle stored procedure output in logfile

Friends, I pass some runtime arguments (date, number) through ksh script to Oracle procedure, use input value and pass it on to procedure. Oracle procedure gets input value, run query and logs everything in the logfile. I'm facing with couple of challenges 1. Even though I pass all... (5 Replies)
Discussion started by: homer4all
5 Replies

3. UNIX for Dummies Questions & Answers

Changes to write output to logfile and console

Friends, Below is the script which writes output to LOGFILE, however I want the entire log written to LOGFILE and also console. Please suggest me the changes I need to do here. #!/bin/ksh x=${0##*/} LOGFILE="x.log" echo "CAUTION : Files once deleted cannot be restored" printf 'Would... (8 Replies)
Discussion started by: fop4658
8 Replies

4. Shell Programming and Scripting

Echo cannot redirect first or second output to logfile

I created a script to do some work. I want to use "echo" to redirect "date" to log file. echo works to screen. But cannot redirect first or second "echo" output to logfile. Please help. My code looks like: STARTTIME=`date +%m-%d-%Y` LOGFILE=/directory/logfile.log echo "Start time:" $STARTTIME... (8 Replies)
Discussion started by: duke0001
8 Replies

5. Shell Programming and Scripting

Unable to create logfile with local time stamp using perl

Hello All, Morning, I am facing problem with my code while creating a log with name as current time stamp using perl. Here is the code. #!/usr/bin/perl my $time=localtime; my ($day,$month,$date,$tm,$year)=split(/ /,$time); my $stamp=$year."_".$month."_".$date; my... (4 Replies)
Discussion started by: krsnadasa
4 Replies

6. Shell Programming and Scripting

how to track a log file of one process and mail that logfile to a group?

Hi Friendz, I have 14 DB load scripts say 1,2,3....14. I want a script to call each script automatically, and after completion of every script, it needs to track the logfile and mail that log file to a group.and again it should run the next script in sequence 1,2,3...14 Please help me,need... (1 Reply)
Discussion started by: shirdi
1 Replies

7. Shell Programming and Scripting

Parse Logfile output variable

<SUMMARY filecount_excluded="0" dirbytes_sent="3367893" dirbytes_hashcache="13275664" ..and so on..> <session numthreads="1" type="avtarbackup" ndispatchers="1" ..and so on..><host numprocs="4" speed="900" osuser="root" name="ashsux01" memory="24545" /><build time="11:04:53" msgversion="13-10" ... (11 Replies)
Discussion started by: Ikon
11 Replies

8. UNIX for Dummies Questions & Answers

Possible to track FTP user last login? Last and Finger don't track them.

Like the topic says, does anyone know if it is possible to check to see when an FTP only user has logged in? Because the shell is /bin/false and they are only using FTP to access the system doing a "finger" or "last" it says they have never logged in. Is there a way to see when ftp users log in... (1 Reply)
Discussion started by: LordJezo
1 Replies

9. UNIX and Linux Applications

how to create a logfile in unix after insert/update/delete from informix

I am running a Informix-4GL program to insert/update/delete on a particular table (say xxx). Now I want to create a logfile in unix which will store the affected data(say xxx.*) along with user information (say uname,IP address etc.) what command I should use from Informix-4GL ? I have tried the... (0 Replies)
Discussion started by: subhamukh
0 Replies

10. Shell Programming and Scripting

Applying diff output to create new script

I believe I read somewhere that you can do a diff of two ksh scripts and use the output to create a new script with the differences. :p Could someone please show me the command(s) I'd need to use to get this accomplished? Or perhaps point me to a thread that explains this in detail. Thanks... (1 Reply)
Discussion started by: BCarlson
1 Replies
Login or Register to Ask a Question