- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Disable error messge
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
09-24-2002 09:29 PM
09-24-2002 09:29 PM
Disable error messge
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-24-2002 09:49 PM
09-24-2002 09:49 PM
Re: Disable error messge
You already have the answer. Redirect stderr to /dev/null. You can still interrogate the return value from 'ls' to determine whether there were any errors or if all file(s) were listed. For instance:
# ls -l /tmp/myfile /tmp/yourfile 2>/dev/null
# echo $?
...would return the listing for
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-24-2002 09:52 PM
09-24-2002 09:52 PM
Re: Disable error messge
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-24-2002 09:59 PM
09-24-2002 09:59 PM
Re: Disable error messge
No. The segregation of normal output (stdout) and error messages into 'stdout' and 'stderr', respectively, is expected for well-written utilities (and scripts). It allows just what you have seen.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-24-2002 10:26 PM
09-24-2002 10:26 PM
Re: Disable error messge
ls $1 2>&1 | grep -v " not "
(presuming that unix file names will not have spaces)
I'm not in a position to try this approach just now, but it should work with some tweaking as needed.
I also wouldn't recommend making an alias named ls, since, as JRF points out, an error upon failure is normal behavior for ls (and most commands, other than those that intentionally fail silently). The results might not be predictable or useful if other scripts were to run with ls behaving as you want it to. Just make yourself a different command that acts like you want it to, via the alias facility.
Hope this helps. Regards, --bmr
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-25-2002 12:57 AM
09-25-2002 12:57 AM