LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-16-2011, 09:40 AM   #1
xerox
Member
 
Registered: Mar 2011
Posts: 43

Rep: Reputation: 0
Unhappy redirecting output of set -x


I have written a script and included the command

Code:
set -x
to see what happening when i run the script.

I want to redirect the output of set -x to a file

Code:
set -x >>file.log
however the above command does not work.

Code:
exec 1>file.log
this command only redirects the output of echo commands not of set -x

Please suggest a solution to redirect the output of this command to a file.
 
Old 03-16-2011, 09:50 AM   #2
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,423

Rep: Reputation: 2823Reputation: 2823Reputation: 2823Reputation: 2823Reputation: 2823Reputation: 2823Reputation: 2823Reputation: 2823Reputation: 2823Reputation: 2823Reputation: 2823
Try it this way:
Code:
./script > file.log 2>&1
 
1 members found this post helpful.
Old 03-17-2011, 03:42 AM   #3
xerox
Member
 
Registered: Mar 2011
Posts: 43

Original Poster
Rep: Reputation: 0
I want do all this redirection from the same script...

when i tried

Code:
./script > file.log 2>&1
the system just hangs....afterwards the file.log is created...can u suggest another method...?

Last edited by xerox; 03-17-2011 at 05:49 AM.
 
Old 03-17-2011, 05:45 AM   #4
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,423

Rep: Reputation: 2823Reputation: 2823Reputation: 2823Reputation: 2823Reputation: 2823Reputation: 2823Reputation: 2823Reputation: 2823Reputation: 2823Reputation: 2823Reputation: 2823
I am not sure I understand what you mean? What i have given you will redirect all output into the log file.
 
Old 03-18-2011, 12:12 AM   #5
xerox
Member
 
Registered: Mar 2011
Posts: 43

Original Poster
Rep: Reputation: 0
I have a script read.sh in which i have the statement set -x

I want redirect the logs of read.sh to a file.log from the script read.sh itself.

The solution you suggested is working file but, once the script is run it doesnt stop, It gets stuck even though the file.log is created.
 
Old 03-18-2011, 11:05 AM   #6
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,423

Rep: Reputation: 2823Reputation: 2823Reputation: 2823Reputation: 2823Reputation: 2823Reputation: 2823Reputation: 2823Reputation: 2823Reputation: 2823Reputation: 2823Reputation: 2823
Well that would mean there is an issue with your script. The redirection will in no way control the scripts exit abilities.
Maybe if you show the read.sh script we can see why it never stops?
 
Old 03-20-2011, 11:08 PM   #7
xerox
Member
 
Registered: Mar 2011
Posts: 43

Original Poster
Rep: Reputation: 0
I have decided not to redirect the output of set-x instead just redirect the error messages to an another log file. I am unable to post the script as it is related to the project i'm working for.

Thank you for your help.
 
Old 03-21-2011, 03:03 AM   #8
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,423

Rep: Reputation: 2823Reputation: 2823Reputation: 2823Reputation: 2823Reputation: 2823Reputation: 2823Reputation: 2823Reputation: 2823Reputation: 2823Reputation: 2823Reputation: 2823
Well my only suggestion would be that you investigate anywhere you have a loop as it may well be there that it is getting stuck.

Also, if you can find a way to take out the secret stuff and show us something supposedly doing the same thing, we may be able to help diagnose the problem.

Good luck
 
1 members found this post helpful.
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Redirecting one output to another file amjadask Linux - Server 3 02-14-2011 12:21 PM
[SOLVED] Redirecting output from stderr mwilner Linux - Newbie 5 12-02-2010 08:25 AM
redirecting output into new script vortmax Linux - General 1 04-25-2008 04:16 PM
A little help with redirecting output tybalt Linux - Newbie 1 08-04-2007 11:08 PM
redirecting output using > cmk77 Slackware 8 11-10-2006 03:08 AM


All times are GMT -5. The time now is 04:23 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration