Writing the output of set -x into Log files


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Writing the output of set -x into Log files
# 1  
Old 07-16-2013
Oracle Writing the output of set -x into Log files

Hi Guys,

I am using set -x in my script to track the flow of the script.

But if i want to write the output of the set -x into a log file, how do i do it?

Thanks,
Ajay
# 2  
Old 07-16-2013
cant u redirect the output of that script to log file?
# 3  
Old 07-16-2013
Quote:
Originally Posted by Ajay Venkatesan
Hi Guys,

I am using set -x in my script to track the flow of the script.

But if i want to write the output of the set -x into a log file, how do i do it?

Thanks,
Ajay
Code:
./myscript 2>tracelog

# 4  
Old 07-18-2013
The output from changing your environment with set -x will be written to Standard Error, file descriptor number 2. If you are doing this within a script and want to capture it to a file, you can:-
Code:
myscript 2>trace_file

If you want to capture Standard Output from the script along with it, you can:-
Code:
myscript >trace_file 2>&1

.... with the 2>&1 directing it to the same as Standard Output. Some shells may have a problem if you try:-
Code:
myscript >trace_file 2>trace_file

and you only get one of the other output saved to the file.


I hope that this helps,
Robin
Liverpool/Blackburn
UK
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Redirecting log files to null writing junk into log files

Redirecting log files to null writing junk into log files. i have log files which created from below command exec <processname> >$logfile but when it reaches some size i am redirecting to null while process is running like >$logfile manually but after that it writes some junk into... (7 Replies)
Discussion started by: greenworld123
7 Replies

2. Shell Programming and Scripting

Not writing output

In the attached bash in the convert function the out_position.txt in not being writing to the annovar directory and I can not figure out why. Thank you :). (2 Replies)
Discussion started by: cmccabe
2 Replies

3. UNIX for Dummies Questions & Answers

Set Command to output a log of every command executed in the script

Hi Guys, I like to output every command executed in the script to a file. I have tried set -x which does the same. But it is not giving the logs of the child script which is being called from my script. Is there any parameters in the Set command or someother way where i can see the log... (2 Replies)
Discussion started by: mac4rfree
2 Replies

4. Shell Programming and Scripting

Help needed with shell script to search and replace a set of strings among the set of files

Hi, I am looking for a shell script which serves the below purpose. Please find below the algorithm for the same and any help on this would be highly appreciated. 1)set of strings need to be replaced among set of files(directory may contain different types of files) 2)It should search for... (10 Replies)
Discussion started by: Amulya
10 Replies

5. UNIX for Dummies Questions & Answers

Writing a loop to manipulate a script and store it in multiple output files

I have a script where the the 9th line looks like this: $filename=sprintf("250.1chr%d.ped", $N); I want to modify this script 1000 times, changing 250.1chr%d.ped to 250.2chr%d.ped, 250.3chr%.ped.......and so on all the way to 250.1000chr%d.ped and store each output in files called ... (4 Replies)
Discussion started by: evelibertine
4 Replies

6. Shell Programming and Scripting

Finding compound words from a set of files from another set of files

Hi All, I am completely stuck here. I have a set of files (with names A.txt, B.txt until L.txt) which contain words like these: computer random access memory computer networking mouse terminal windows All the files from A.txt to L.txt have the same format i.e. complete words in... (2 Replies)
Discussion started by: shoaibjameel123
2 Replies

7. Shell Programming and Scripting

Format the output from sqlplus while writing to log file.

Hi I have developed bash script to connect to database and execute .sql files. I am logging some statements in to log file using echo. While logging I am adding the date in front of the log statements which makes sense. I am unable to add date in front of output from the sqlplus and sqlldr,... (8 Replies)
Discussion started by: murtymvvs
8 Replies

8. Shell Programming and Scripting

Writing output into different files while processing file using AWK

Hi, I am trying to do the following using AWK program. 1. Read the input data file 2. Parse the record and see if it contains errors 3. If the record contains errors, then write it into Reject file, else, write into usual output file or display it on the screen Here is what I have done -... (6 Replies)
Discussion started by: vidyak
6 Replies

9. UNIX for Dummies Questions & Answers

Redirecting output to multiple log files?

If I wanted to redirect output to multiple log files, what would be the best way to do that? echo "Unix is awesome" >>unixgod.log >>unixgod.log (3 Replies)
Discussion started by: darthur
3 Replies
Login or Register to Ask a Question