- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: How to redirection Standard error to an env va...
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
05-30-2005 09:35 AM
05-30-2005 09:35 AM
I would like to redirect such error to an environment variable, and compare the error strings, then echo some friendly words to the standard output.
I know I can redirect the error to a file, like:
ldappasswd
But is it possible to redirect the standard error to a variable ?
Thanks!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-30-2005 09:54 AM
05-30-2005 09:54 AM
Re: How to redirection Standard error to an env variable instead of a file
try ldappasswd 2>&1 >/dev/null
greetings,
Michael
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-30-2005 10:00 AM
05-30-2005 10:00 AM
Re: How to redirection Standard error to an env variable instead of a file
if the script you are using doesnot throw up any output message and only error output..
u could write a script like this...
------------------------------------
#!/usr/bin/sh
ERR=`/path/ldappasswd 2>&1`
if [ ERR .....form here on your logic...
------------------------------------
The character around /path/ldappasswd 2>&1 is a back quote ,the one u find before "key 1" in KB.
NOTE:
But mind you, if the error message is multilined..the "\n" enter character will be stripped off and made into single line and put in the variable.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-30-2005 11:07 PM
05-30-2005 11:07 PM
Re: How to redirection Standard error to an env variable instead of a file
ldappasswd
if [[ $? -eq 0 ]]
then
echo "action got error"
else
echo "ok"
fi
grep -q will be used to search string in silent mode.
hth.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-30-2005 11:14 PM
05-30-2005 11:14 PM
SolutionI copyied only half of what I wanted.
That should have been
ERR=`ldappasswd 2>&1 >/dev/null`
which is roughly the same as that from senthil.
If you need the stdout too then you can redirect stderr to file and read it into a variable.
ldappasswd args 2>errorlog
ERR=`cat errorlog`
Michael
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-31-2005 04:23 AM
05-31-2005 04:23 AM
Re: How to redirection Standard error to an env variable instead of a file
# ERR=$(ldappasswd
OR
# ERR=`ldappasswd
both these forms should work.