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
Script to capture new lines in a file and copy it to new file fara_aris Shell Programming and Scripting 0 05-27-2008 10:11 PM
[csh] How to capture output from a command and pass it on to a variable? machinogodzilla Shell Programming and Scripting 3 05-11-2008 09:36 AM
Capture entire line in ps command MizzGail Shell Programming and Scripting 2 05-08-2008 12:46 PM
capture the file name Mandab Shell Programming and Scripting 4 05-29-2007 10:22 AM
Capture Value from file kris01752 UNIX for Advanced & Expert Users 1 08-28-2006 10:50 PM

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 08-08-2006
ahmedwaseem2000 ahmedwaseem2000 is offline
Registered User
  
 

Join Date: Aug 2005
Location: Bangalore
Posts: 219
Capture the command run in the log file

Hi ,

I have seen some log files where they have captured the command that is being executed, comments present in the scripts and the out put of the command as well, through scripts. could any one of you please let me know how do i do that?

Thanks in advance.

Cheers,
Waseem
  #2 (permalink)  
Old 08-08-2006
tmarikle tmarikle is offline Forum Advisor  
Registered User
  
 

Join Date: Jan 2005
Posts: 683
Code:
echo "yourcommand args" > log_file.txt
yourcommand args >> log_file.txt
or maybe it's running a trace and capturing output and tracing execution:
Code:
{
    set -x
    yourcommand args
    set +x
} > yourlog.txt 2>&1
  #3 (permalink)  
Old 08-09-2006
ahmedwaseem2000 ahmedwaseem2000 is offline
Registered User
  
 

Join Date: Aug 2005
Location: Bangalore
Posts: 219
Oh- i never knew that, you could capture even the comments b tracing. i guess, you are right, as they are using set -vf probably thats how they are accomplishing this.


also, incase of command failures will the script teminate? like, in the below code, the file is not found so i want the script to terminate? if yes, then, how do i avoid from script terminating. for instance, i would want to ignore even if the file is not present and continue running the next commands?????

Code:
{
set -x
rm filename
rm: could not find the file
set +x
i will test it later. anyways thanks for your help!!!

Cheers,
Waseem

Last edited by ahmedwaseem2000; 08-09-2006 at 03:29 AM..
  #4 (permalink)  
Old 08-09-2006
tmarikle tmarikle is offline Forum Advisor  
Registered User
  
 

Join Date: Jan 2005
Posts: 683
No, the script will not terminate unless you want it to.
Code:
if ! rm filename
then
    exit 1
fi
  #5 (permalink)  
Old 08-09-2006
ahmedwaseem2000 ahmedwaseem2000 is offline
Registered User
  
 

Join Date: Aug 2005
Location: Bangalore
Posts: 219
Hey thanks for your reply.

as i do not have the access to a unix box right now, so i will try it later.

Many Thanks,

Cheers - Waseem
Sponsored Links
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 01:05 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