- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: redirection problem
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-08-2004 05:04 PM
02-08-2004 05:04 PM
redirection problem
between 1>#ls >file 2>&1 and
2>#ls 2>&1 >file
why the 2nd cmd not redirecting the std error
to the file?
If any one knows anything pls let me know.
Amit Singh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-08-2004 05:17 PM
02-08-2004 05:17 PM
Re: redirection problem
"kjk 2>&1 >file 2>&1" although stupid achieves what you would expect if the above paragraph is true.
I think the point is that "2>&1" doesn't mean "glue" standard error to standard output but means direct standard error to wherever standard output happens to be right now.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-08-2004 05:27 PM
02-08-2004 05:27 PM
Re: redirection problem
enclose the command within parenthesis or braces and you dont have the problem:
ls nosuchfile 2>&1 >log #doesnt work
(ls nosuchfile 2>&1) > log # works
{ ls nosuchfile 2>&1 \
} > log #works
also if you put the offending line within a script file and run it (redirecting stdout) it still works.
--
ranga
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-08-2004 07:15 PM
02-08-2004 07:15 PM
Re: redirection problem
Ur explanation is good.
do U have any document explaning the fact?
or do U have any info from where I will get
the HP internals book.
thanks..
Amit Singh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-08-2004 07:23 PM
02-08-2004 07:23 PM
Re: redirection problem
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-08-2004 10:44 PM
02-08-2004 10:44 PM
Re: redirection problem
check the man-page from sh-posix.
Quote:
If any of the above redirections is preceded by a digit (0 to 9), the file descriptor used is the one specified by
the digit, instead of the default 0 (standard input) or 1 (standard output). For example:
2>&1
means open file descriptor 2 for writing as a duplicate of file descriptor 1. Output directed to file descriptor
2 is written in the same location as output to file descriptor 1.
Order is significant in redirection. The shell evaluates each redirection in terms of the (file descriptor, file)
assignment at the time of evaluation. For example:
1>fname 2>&1
first assigns file descriptor 1 to file fname. It then assigns file descriptor 2 to the file assigned to file
descriptor 1 (that is, fname).
If the order of redirection is reversed, as in
2>&1 1>fname
file descriptor 2 is assigned to the file assigned to file descriptor 1 (probably the terminal) and then file
descriptor 1 is assigned to file fname.
JP.
(Glad to help, bu if this answer or any of the above help you, would you assign some points?)