Log file issue within script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Log file issue within script
# 1  
Old 09-22-2009
Log file issue within script

Hi,

I have a script where it does several tasks and 3 of them being SQLPLUS activity. Within these SQLPLUS sessions, I have a spool file going but what ever is going on within each SQLPLUS session I would like to write it to my main log file where everything else is running.

Code:
sqlplus -s << EOF
gillray/$PASSWORD
#dradmin/$PASSWORD
spool /home/dradmin/logs/COMP_IndexCountBefore.txt
@/home/dradmin/scripts/COMP_Index_Count.sql
spool off
exit
EOF

So basically whatever is happening here, I would like to send to main log file which is capturing everything else.

Code:
LogDir=/home/dradmin/logs/
LogFile=${LogDir}`echo $MyName | sed "s/ksh$/log/g"`  # name of log file
CurrLogFile=${LogDir}`echo $MyName | sed "s/ksh$/log.curr/g"`  # Name of the current log file

How would I acheive this. I am stumped.
# 2  
Old 09-22-2009
Instead of using spool in your sqlplus heredocs, try some combination of sqlplus output settings which output to std out. Remember, spool diverts sqlplus output to a file, so removing it should give you what you want.

See sqlplus set command for reference.
# 3  
Old 09-23-2009
Quote:
Originally Posted by varontron
Instead of using spool in your sqlplus heredocs, try some combination of sqlplus output settings which output to std out. Remember, spool diverts sqlplus output to a file, so removing it should give you what you want.

See sqlplus set command for reference.
I have enabled "SET SERVEROUTPUT ON". I am trying this approach now to see if it yields my desired results.

Code:
sqlplus -s <<EOF >>$CurrLogFile
userx/$PASSWORD
@/home/scripts/rebuild_index.sql
@/home/scripts/run_rebuild_index.sql
exit
EOF

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

UNIX Log File Content - Duplication Issue

I have a shell script with 2 run time arguments. During the execution if i got any error, then it needs to redirected to a error file and in console. Also both error and output to be redirected to a log file. Error output is getting copied to err file and getting displayed in console too. But... (2 Replies)
Discussion started by: sarathy_a35
2 Replies

2. Shell Programming and Scripting

Log script issue

I'm writing a script that will monitor in real time the log file for some messages and then kill the monitor script if it find a particular message. I have written similar type of script and its working for other logs(small log files), but for one particular log the below code is not working. I... (6 Replies)
Discussion started by: vinus
6 Replies

3. Shell Programming and Scripting

Issue with awk script parsing log file

Hello All, I am trying to parse a log file and i got this code from one of the good forum colleagues, However i realised later there is a problem with this awk script, being naive to awk world wanted to see if you guys can help me out. AWK script: awk '$1 ~ "^WRITER_" {p=1;next}... (18 Replies)
Discussion started by: Ariean
18 Replies

4. Shell Programming and Scripting

Mac script - issue with tab delimited input file

Hi: I'm writing a script that will take source / destination pathnames and metadata information from a tab-delimited input file, and then perform various directory creation, file moving and renaming, and tagging of files. I think I have what I need to do the file manipulation in the script -... (4 Replies)
Discussion started by: GRIMESPACE
4 Replies

5. UNIX for Dummies Questions & Answers

Issue with use of Configuration file instead of hardcoded values inside the script

Hi, My code works perfectly fine. But, $my $min_to_add = 1 * 1 * 60; and my $hr_to_sub = 1 * 1 * 86400; i may need to change the values in future. so am keeping them in a separate configuration file like MIN = 1 * 1 * 60 HR = 24 * 60 * 60 in the script, i use a package use et_config... (3 Replies)
Discussion started by: irudayaraj
3 Replies

6. Shell Programming and Scripting

Log rotation issue with script

I have application which to the heavy stdout and I have diverted the stdout to log file. this log file is writing very heavily and we have a script which rotates the logs. logic for rotation is smthing like cp logfile logfile.1 cat /dev/null > logfile this logic was working fine till we... (3 Replies)
Discussion started by: navinmistry
3 Replies

7. Shell Programming and Scripting

An Issue with the script which used to remove a file from the current directory.

Hello forum members, I am writing a script to two tasks. 1: displaying the list of the files in the current directory. 2: removing the specifed file from the list. I have written a sample script ,so can u please verfiy and correct. echo Enter list of files ls *.txt read textfile rm -f... (3 Replies)
Discussion started by: sivaranga001
3 Replies

8. Shell Programming and Scripting

issue invoking shell script using cron, even with proper file permission

I am using tcsh what could possibly be a problem, when using crontab to invoke a shell script. ? The script has the read, write and execute permission to all users. And the script works as expected while executing it in stand-alone mode. Is there a way to trace (like log) what error... (9 Replies)
Discussion started by: vikram3.r
9 Replies

9. UNIX for Dummies Questions & Answers

Issue with shell script: not detecting file properly

The following script is meant to check the presence of a file - called filename0.94.tar.gz - and uncompress it: #!/bin/sh # check presence of file VERSION=0.94 if ; then # file not present: abort echo "Files cannot be found." #exit 1 (commented out this line, so we can see how the... (2 Replies)
Discussion started by: figaro
2 Replies

10. UNIX for Dummies Questions & Answers

Issue with shell Script file

Hi, I created the following shell script file : bash-3.00$ more Unlock_Statistics1.sh #!/usr/bin/ksh ORACLE_SID=prsal02; export ORACLE_SID NLS_LANG=AMERICAN_AMERICA.AL32UTF8; export NLS_LANG sqlplus -s /nolog << EOF connect / as sysdba ; set serveroutput on size 1000000; execute... (1 Reply)
Discussion started by: jalpan.pota
1 Replies
Login or Register to Ask a Question