The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Background execution of a script Cameron Shell Programming and Scripting 2 10-03-2007 05:50 AM
error during the execution of script surjyap Shell Programming and Scripting 1 08-24-2007 08:10 PM
Pb with script execution and variables Cecile AIX 1 09-15-2006 09:54 AM
pb with script execution Cecile UNIX for Dummies Questions & Answers 3 09-14-2006 10:37 AM
execution of shell script malaymaru Shell Programming and Scripting 5 06-13-2005 09:49 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 07-04-2006
manthasirisha manthasirisha is offline
Registered User
  
 

Join Date: Jan 2006
Posts: 59
Script execution information

I want to catch the execution information of a script by calling it from another script....

script_main:

#! /bin/ksh


ksh -x script2.ksh >> tmplog

....

but this doesn't give me anything but the error msgs of script in tmplog.

can anyone pls suggest which is the right method? The idea is to run the script2 from script1 and catch the log of execution.

I went through a similar thread but it doesn't answer my question completely and that too, it's closed already.

Thanks in advance!
  #2 (permalink)  
Old 07-04-2006
thestevew thestevew is offline
Registered User
  
 

Join Date: Mar 2006
Location: South Yorkshire, UK
Posts: 114
You need to redirect std err as well - that's where the debug information is written:
Code:
ksh -x script2.ksh >> tmplog 2>&1
  #3 (permalink)  
Old 07-05-2006
manthasirisha manthasirisha is offline
Registered User
  
 

Join Date: Jan 2006
Posts: 59
Thanks thestevew,

I didn't know this one.. but this works only when i do:

ksh -x script2.ksh >>tmplog 2>&1 at the prompt

the same doesn't work for me from the script1..
This is how my script1.ksh looks:

if [ ! `ps -e | script2.ksh ]
then
`ksh -x script2.ksh >> tmplog 2 >&1`
else
echo "script2 already running"
exit 1
fi


Also I have quite a few functions that call one another in script2.ksh.. can you pls tell me how can I catch what's happening within a function when script2.ksh is being run? As far as I know, the above gives only the names of the functions in the order they're called...

for ex:
script2.ksh has variables a,b,c and it has functions f1, f2. f1 calls f2 and in both f1 and f2 there are variables d & e respectively.. when
ksh -x script2.ksh >> tmplog 2>&1 is done..

tmplog contains the below:

+ a=assigned value
+ b=assigned value
+ c=assigned value
+ f1
+ f2
...

Your help is much appreciated!

Thanks!
  #4 (permalink)  
Old 07-06-2006
manthasirisha manthasirisha is offline
Registered User
  
 

Join Date: Jan 2006
Posts: 59
FYI,
I even tried executing script2 from script1 as

. script2.ksh >> tmplog 2 >&1

and now I get syntax error: '(' unexpected

any clues of what the mistake is??

Thanks again!
  #5 (permalink)  
Old 07-06-2006
grial's Avatar
grial grial is offline Forum Advisor  
El UNIX es como un toro
  
 

Join Date: Jun 2006
Location: Madrid (Spain)
Posts: 531
We won't be able to tell you what's happening without the code
Regards.
  #6 (permalink)  
Old 07-06-2006
manthasirisha manthasirisha is offline
Registered User
  
 

Join Date: Jan 2006
Posts: 59
Thank you so much thestevew and grial.. for your inputs!

here's my code:


script1:
#! /bin/ksh

BBLOG="$HOME/bb_quickview/Log"
datestamp=`TZ=EDT+24 date +%m%d%y`
retcode=$?

if [ `ps -e | grep script1.ksh` ]
then
stat=`ksh -x script2.ksh` >> $BBLOG/$datestamp.log 2 >&1
echo retcode
else
echo "Script2 already running"
exit 1
fi


Script 2:
it's 300 line script that fetches different values by connecting to database (Oracle) and writes all these values into an output file that is later emailed.

This much is achieved by means of functions:

func_read_configfile ##to read the configuration variables

func_connectstring ##to read connection information

get_counts ## to fetch the desired values from DB and mail them

recheck_counts ## to handle exceptions if counts are not available in the database

archive ## to zip the output file and save in Archive directory

cleanup ## to remove any temporay files

pls note that I cannot paste all lines of the code here.. coz i'm writing from a browser that's connected with a server of restricted access. I, in no way, can copy-paste from my script.

The whole issue before me is to see how the script2 runs, what happens in each of these functions, what values are assigned to variables (if any) in the functions and thus save all this information.. kind of a "LOG" which helps in tracing errors if anything fails.


ERRORs / Concerns: When I run script1.ksh i see all the debug info on the STDOUT rather than in the LOG i want to create. I only am able to redirect the error messages that Script2 generates into the LOG.. :-S


I hope this would suffice to pour in your suggestions.

Lots of Thanks!
  #7 (permalink)  
Old 07-06-2006
thestevew thestevew is offline
Registered User
  
 

Join Date: Mar 2006
Location: South Yorkshire, UK
Posts: 114
To get more debugging in functions add
Code:
set -x
at the top of the function code (inside the {}).
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 06:32 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0