|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
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 |
| Sponsored Links | ||
|
|
#2
|
|||
|
|||
|
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 |
| Sponsored Links | ||
|
|
#3
|
|||
|
|||
|
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 +xi will test it later. anyways thanks for your help!!! Cheers, Waseem
Last edited by ahmedwaseem2000; 08-09-2006 at 03:29 AM.. |
|
#4
|
|||
|
|||
|
No, the script will not terminate unless you want it to. Code:
if ! rm filename
then
exit 1
fi |
| Sponsored Links | |
|
|
#5
|
|||
|
|||
|
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 | ||
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to capture Output of truus command | ankush_mehra | Solaris | 1 | 04-18-2012 12:03 PM |
| How do I capture responses from the chat command? | Bashingaway | Linux | 8 | 02-14-2011 10:54 AM |
| Doing a capture while another command is executing? | MrEddy | UNIX for Dummies Questions & Answers | 0 | 04-20-2010 02:55 PM |
| Enter the command to capture output--help | rrd1986 | Shell Programming and Scripting | 1 | 02-02-2010 05:33 PM |
| Capture entire line in ps command | MizzGail | Shell Programming and Scripting | 2 | 05-08-2008 12:46 PM |
|
|