Sponsored Content
Full Discussion: Formatting the Log file
Top Forums Shell Programming and Scripting Formatting the Log file Post 302108209 by hegemaro on Saturday 24th of February 2007 08:04:09 AM
Old 02-24-2007
If I understand your question correctly, you want to run a script which calls multiple commands all of which are redirected to a single logfile. You can redirect the STDOUT and STDERR upon entry into the calling script. All subsequent commands will inherit the redirection from the calling script.

Code:
#!/bin/ksh

    exec 1>>/var/log/script.log 2>&1

    command1
    command2
    command3

One short-coming would be that you would not necessarily know which command generated which errors unless they're sufficiently different. By adding an echo before each command, you would know in which command you were when messages were generated.
Code:
#!/bin/ksh

    exec 1>>/var/log/script.log 2>&1

    echo "$0 (I) Starting command1"
    command1
    echo "$0 (I) Starting command2"
    command2
    echo "$0 (I) Starting command3"
    command3

Upon reflection, I don't think I'm grasping the problem. Could you please provide a little more detail? Thanks.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help with formatting of file.

I have a file with following file format - DMCRH|||83000171|||14022008||0430|||8956612.23|J|||3571235|1378452|23468|6894|9234| DMCRH|||83000215|||15092007||0480|||121.33|J|||LineID003|RefNumSP003|RefNumMem003|0004|0003| What i need done is - 1. Cut the firt four digits of the date (eg 1402... (3 Replies)
Discussion started by: divz
3 Replies

2. UNIX for Dummies Questions & Answers

Formatting a file.

I want to format a file to limit record length = 100, in each line. Any idea how i can do this? (1 Reply)
Discussion started by: abhilasha
1 Replies

3. Shell Programming and Scripting

help with file formatting

Hi, I have a file with below contents: AAA pqr,jkl,mnop,abcd BBB abc,pqrs,xyz,uvw, efgh,uvw, rpk CCC 123,456,789 Need output file as below: AAA,pqr,jkl,mnop,abcd BBB,abc,pqrs,xyz,uvw,efgh,uvw,rpk (18 Replies)
Discussion started by: prvnrk
18 Replies

4. Shell Programming and Scripting

Formatting a file....

Hi, I have written a script which directs output of vmstat to a file... The file consists of 15 lines in all..... Through scripting I would like to re-format the file excluding first 4 lines... I donot wish to use vi editor and manually delete lines but i want this process to be... (2 Replies)
Discussion started by: EmbedUX
2 Replies

5. Shell Programming and Scripting

File Formatting

Hi, Need to delete all the records prior to pattern (INSERT/UPDATE/DELETE). If ' is available, then need to retain it. Input ====================== l_s := ' INSERT INTO TEST' l_P PD := ' UPDATE INTO TEST' l_D := ' DELETE INTO TEST' This is test Input ======================... (1 Reply)
Discussion started by: saurabhbaisakhi
1 Replies

6. Shell Programming and Scripting

File Formatting

Hi, Need to delete all the records prior to pattern (INSERT/UPDATE/DELETE). If ' is available, then need to retain it. Input ====================== l_s := ' INSERT INTO TEST' l_P PD := ' UPDATE INTO TEST' l_D := ' DELETE INTO TEST' This is test Output ======================... (1 Reply)
Discussion started by: saurabhbaisakhi
1 Replies

7. Shell Programming and Scripting

Formatting file data to another file (control character related)

I have to write a program to read data from files and then format into another file. However, I face a strange problem related to control character that I can't understand and solve. The source file is compose of many lines with such format: T_NAME|P_NAME|P_CODE|DOCUMENT_PATH|REG_DATE ... (3 Replies)
Discussion started by: hk6279
3 Replies

8. Shell Programming and Scripting

HP IML log formatting

HP hardware Linux SLES version 10 shell script, ksh or sh I am taking the output of the IML log and ultimately want to find only entries 30 days old. I am getting some unexpected results along the way. hpasmcli -s "SHOW IML" Event: 4 Added: 06/12/2012 13:56 INFO: Maintenance Note -... (3 Replies)
Discussion started by: snoman1
3 Replies

9. Shell Programming and Scripting

Formatting a file

Hi Experts I have a file which looks as follows acttest /report/fieldsinf/acttest/LIVE/acttest Chris New teatin1 /report/fieldsinf/eatin1/TEST/teatin1 Chris New eatin1 /report/fieldsinf/eatin1/LIVE/eatin1 Chris New tbectest ... (7 Replies)
Discussion started by: maverick_here
7 Replies

10. UNIX for Dummies Questions & Answers

Formatting data in a raw file by using another mapping file

Hi All, i have a requirement where i need to format the input RAW file ( which is CSV) by using another mapping file(also CSV file). basically i am getting feed file with dynamic headers by using mapping file (in that target field is mapped with source filed) i have to convert the raw file into... (6 Replies)
Discussion started by: ravi4informatic
6 Replies
escape(1)							Mail Avenger 0.8.3							 escape(1)

NAME
escape - escape shell special characters in a string SYNOPSIS
escape string DESCRIPTION
escape prepends a "" character to all shell special characters in string, making it safe to compose a shell command with the result. EXAMPLES
The following is a contrived example showing how one can unintentionally end up executing the contents of a string: $ var='; echo gotcha!' $ eval echo hi $var hi gotcha! $ Using escape, one can avoid executing the contents of $var: $ eval echo hi `escape "$var"` hi ; echo gotcha! $ A less contrived example is passing arguments to Mail Avenger bodytest commands containing possibly unsafe environment variables. For example, you might write a hypothetical reject_bcc script to reject mail not explicitly addressed to the recipient: #!/bin/sh formail -x to -x cc -x resent-to -x resent-cc | fgrep "$1" > /dev/null && exit 0 echo "<$1>.. address does not accept blind carbon copies" exit 100 To invoke this script, passing it the recipient address as an argument, you would need to put the following in your Mail Avenger rcpt script: bodytest reject_bcc `escape "$RECIPIENT"` SEE ALSO
avenger(1), The Mail Avenger home page: <http://www.mailavenger.org/>. BUGS
escape is designed for the Bourne shell, which is what Mail Avenger scripts use. escape might or might not work with other shells. AUTHOR
David Mazieres Mail Avenger 0.8.3 2012-04-05 escape(1)
All times are GMT -4. The time now is 07:28 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy