The UNIX and Linux Forums  


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
Redirecting STDERR message to STDOUT & file at same time vikashtulsiyan Shell Programming and Scripting 10 04-09-2008 03:34 PM
redirect stderr and/or stdout to /dev/null from command line knc9233 UNIX for Dummies Questions & Answers 1 01-25-2007 12:24 PM
stderr & stdout to a file and the right exit code up69 Shell Programming and Scripting 2 08-17-2006 02:40 PM
Redirect stdout & stderr and append to a file Santi Shell Programming and Scripting 2 01-02-2006 07:58 PM
Redirect stdout and stderr zcurtis Shell Programming and Scripting 8 09-02-2002 07:13 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 08-28-2008
sushantnirwan sushantnirwan is offline
Registered User
  
 

Join Date: Aug 2008
Posts: 8
Question How to redirect stderr and stdout to a file

Hi friends
I am facing one problem while redirecting the out of the stderr and stdout to a file
let example my problem with a simple example
I have a file (say test.sh)in which i run 2 command in the background

ps -ef &
ls &

and now i am run this file and redirect the output to a file (say output.log)
./test.sh > output.log

Now the result stored in the file is not like that first ps -ef and than ls
it mixed the output of both command

Now help me so thats i can store the result in the file only one after another

Thanks
  #2 (permalink)  
Old 08-28-2008
vidyadhar85's Avatar
vidyadhar85 vidyadhar85 is offline Forum Staff  
Moderator(The Tutor)
  
 

Join Date: Jun 2008
Location: INDIA
Posts: 1,407
Quote:
Originally Posted by sushantnirwan View Post
Hi friends
I am facing one problem while redirecting the out of the stderr and stdout to a file
let example my problem with a simple example
I have a file (say test.sh)in which i run 2 command in the background

ps -ef &
ls &

and now i am run this file and redirect the output to a file (say output.log)
./test.sh > output.log

Now the result stored in the file is not like that first ps -ef and than ls
it mixed the output of both command

Now help me so thats i can store the result in the file only one after another

Thanks
its because when you run them in background they will run simultaniously..
  #3 (permalink)  
Old 08-28-2008
sushantnirwan sushantnirwan is offline
Registered User
  
 

Join Date: Aug 2008
Posts: 8
Quote:
Originally Posted by vbe View Post
2>&1 ...
This replies to your thread title...
Quote:
Originally Posted by vidyadhar85 View Post
its because when you run them in background they will run simultaniously..
Ya i know , but what the way to come out from this problem
  #4 (permalink)  
Old 08-28-2008
fpmurphy's Avatar
fpmurphy fpmurphy is offline Forum Staff  
Moderator
  
 

Join Date: Dec 2003
Location: Florida
Posts: 1,935
Run your whole shell script in the background; not the individual commands within the shell script.
  #5 (permalink)  
Old 08-28-2008
vbe's Avatar
vbe vbe is online now Forum Staff  
Moderator
  
 

Join Date: Sep 2005
Location: Switzerland - GE
Posts: 1,578
2>&1 ...
This replies to your thread title...

Last edited by vbe; 08-28-2008 at 06:33 AM..
  #6 (permalink)  
Old 08-28-2008
vbe's Avatar
vbe vbe is online now Forum Staff  
Moderator
  
 

Join Date: Sep 2005
Location: Switzerland - GE
Posts: 1,578
But I dont get you here, whats the point of launching these 2 cmds in background?
  #7 (permalink)  
Old 08-28-2008
sushantnirwan sushantnirwan is offline
Registered User
  
 

Join Date: Aug 2008
Posts: 8
Its not cmds, I am taking it as a example , other are files which i did not explain here
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 10:12 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