The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
search for a file - errors redirected matrixmadhan AIX 1 07-18-2005 04:12 AM
redirected output slavam Shell Programming and Scripting 2 10-12-2004 01:47 PM
tail -f a log file redirected into a new window? douknownam Shell Programming and Scripting 2 06-01-2004 04:34 PM
Standard output not redirected from /bin/sh soorajmu UNIX for Dummies Questions & Answers 1 09-19-2003 10:47 AM
Saving a redirected file JSP UNIX for Dummies Questions & Answers 1 09-27-2001 06:52 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 09-28-2007
brdholman brdholman is offline
Registered User
  
 

Join Date: Sep 2007
Posts: 26
redirected output not going to file for all cases

I have to confirm that an engine was not able to run. In the output below you see that it indeed got errors, but it didn't send those messages to the output file. When I run the same thing with a different executable it works. So does this mean something in the executable could cause it not to go to the output file??

$ cd Tar
$ ./Engine > ../engine_output.txt
exec(): 0509-036 Cannot load program ./Engine because of the following errors:
0509-150 Dependent module libodbc.a(libodbc.so.1) could not be loaded.
0509-022 Cannot load module libodbc.a(libodbc.so.1).
0509-026 System error: A file or directory in the path name does not exist.
$ cd ..
$ cat engine_output.txt
$ ls
AIX_50_ODBC_test.sh engine.tar engine_result.txt
Tar engine_output.txt
$
  #2 (permalink)  
Old 09-28-2007
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,643
The errors are going to stderr (2) Normal output goes to stdout (1)

Code:
$ ./Engine 2>&1 > ../engine_output.txt
This makes both streams go to ../engine_output.txt
  #3 (permalink)  
Old 09-28-2007
reborg's Avatar
reborg reborg is offline Forum Staff  
Administrator
  
 

Join Date: Mar 2005
Location: Ireland
Posts: 4,190
Quote:
Originally Posted by jim mcnamara View Post
The errors are going to stderr (2) Normal output goes to stdout (1)

Code:
$ ./Engine 2>&1 > ../engine_output.txt
This makes both streams go to ../engine_output.txt
It won't make both streams go to the file becasue 2 is duplicated to 1 before 1 is redirected to the file. As a result stdout goes to the file and stderr goes to stdout.
Code:
$ ./Engine > ../engine_output.txt 2>&1
  #4 (permalink)  
Old 09-28-2007
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,643
You're correct, but as far as this code goes, both streams end up written to to log file.
  #5 (permalink)  
Old 09-28-2007
reborg's Avatar
reborg reborg is offline Forum Staff  
Administrator
  
 

Join Date: Mar 2005
Location: Ireland
Posts: 4,190
I disagree:

Code:
#!/bin/ksh
#
# test.sh : demonstrate redirection
#
#
echo "I am stdout"
echo "I am stderr" >&2
Code:
# ./test.sh > log1
I am stderr
# cat log1
I am stdout
Code:
# ./test.sh 2>&1 > log2
I am stderr
# cat log2
I am stdout
Code:
# ./test.sh > log3 2>&1
# cat log3
I am stdout
I am stderr
The order of redirection is important because if the duplication happens from 2 to 1 before redirection of 1, error output is redirected to fd1 ( stdout ) and standard output is redirected elsewhere. On the other hand if it happens afterwards the duplication is to "the same place as standard output"
  #6 (permalink)  
Old 10-02-2007
brdholman brdholman is offline
Registered User
  
 

Join Date: Sep 2007
Posts: 26
Thanks guys. This helps alot.
  #7 (permalink)  
Old 10-04-2007
brdholman brdholman is offline
Registered User
  
 

Join Date: Sep 2007
Posts: 26
This works for all my normal executions. But on one machine, a coredump is expected on one command. We don't care, just need to confirm the version info. This is output from the exe:

$ ./Up


-*-*- XXXXXXX UPDATE XXXXX Version nnnnnnnn -*-*-
-*-*- Copyright (C) 1998-2007 xxxxxxxxxxxxxx, Inc. -*-*-

Processing begins: 10/4/2007 10:48:12

Tracking Database Connect Error
Memory fault(coredump)

However, when I send the output to a file, the output file is empty:

$ ./Up > ../Up_output.txt 2>&1
Memory fault(coredump)
$ cd ..
$ cat Up_output.txt
$
Sponsored Links
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 06:36 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
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