The UNIX and Linux Forums  

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 01:12 AM
redirected output slavam Shell Programming and Scripting 2 10-12-2004 10:47 AM
tail -f a log file redirected into a new window? douknownam Shell Programming and Scripting 2 06-01-2004 01:34 PM
Standard output not redirected from /bin/sh soorajmu UNIX for Dummies Questions & Answers 1 09-19-2003 07:47 AM
Saving a redirected file JSP UNIX for Dummies Questions & Answers 1 09-27-2001 03:52 PM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 09-28-2007
Registered User
 

Join Date: Sep 2007
Posts: 26
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit! Stumble this Post!Spurl this Post!
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
$
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 09-28-2007
...@...
 

Join Date: Feb 2004
Location: NM
Posts: 3,289
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit! Stumble this Post!Spurl this 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
Reply With Quote
  #3 (permalink)  
Old 09-28-2007
reborg's Avatar
Administrator
 
Join Date: Mar 2005
Location: Ireland
Posts: 3,439
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit! Stumble this Post!Spurl this Post!
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
Reply With Quote
  #4 (permalink)  
Old 09-28-2007
...@...
 

Join Date: Feb 2004
Location: NM
Posts: 3,289
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit! Stumble this Post!Spurl this Post!
You're correct, but as far as this code goes, both streams end up written to to log file.
Reply With Quote
  #5 (permalink)  
Old 09-28-2007
reborg's Avatar
Administrator
 
Join Date: Mar 2005
Location: Ireland
Posts: 3,439
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit! Stumble this Post!Spurl this Post!
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"
Reply With Quote
  #6 (permalink)  
Old 10-02-2007
Registered User
 

Join Date: Sep 2007
Posts: 26
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit! Stumble this Post!Spurl this Post!
Thanks guys. This helps alot.
Reply With Quote
  #7 (permalink)  
Old 10-04-2007
Registered User
 

Join Date: Sep 2007
Posts: 26
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit! Stumble this Post!Spurl this Post!
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
$
Reply With Quote
  #8 (permalink)  
Old 10-10-2007
Registered User
 

Join Date: Sep 2007
Posts: 26
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit! Stumble this Post!Spurl this Post!
Is there any way to get this error messages to go to the output file?
Reply With Quote
Google UNIX.COM
Reply

Thread Tools
Display Modes


The 50 most popular UNIX and Linux searches.
Google Search Cloud for The UNIX and Linux Forums
421 service not available, remote server has closed connection ^m automate ftp autosys awk trim bash eval bash for loop boot: cannot open kernel/sparcv9/unix command copy/move folder in unix couldn't set locale correctly curses.h cut command in unix find grep find mtime find null character in a unix file grep multiple lines grep or grep recursive hp-ux ifconfig inaddr_any inappropriate ioctl for device lynx javascript mailx attachment mget mtime ping port remove first character from string in k shell replace space by comma , perl script rsync ftp scp recursive segmentation fault(coredump) sftp script snoop unix solaris change ip address stale nfs file handle syn_sent tar exclude tar extract to folder test: argument expected unix unix .profile unix forum unix forums unix internals unix interview questions unix mtime unix simulator unix.com vi substitute while loop within while loop shell script


All times are GMT -7. The time now is 03:21 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101