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 > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How can I identify the last saved log? gugs Shell Programming and Scripting 20 10-14-2008 06:55 PM
script in saved in compress format naveeng.81 Shell Programming and Scripting 1 04-14-2008 09:31 AM
Sudo file not saved Asteroid UNIX for Advanced & Expert Users 0 07-30-2007 08:18 AM
only root's crontab gets not saved flok UNIX for Advanced & Expert Users 1 06-25-2007 11:50 AM
Where are the password saved in a UNIX server? hast5 UNIX for Dummies Questions & Answers 12 10-19-2006 05:11 PM

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 04-17-2009
lavascript lavascript is offline
Registered User
  
 

Join Date: Apr 2009
Posts: 47
Thumbs down Can STDERR be saved to a variable

Guys i'm trying to save STDERR to a variable for a portion of my ksh script on solaris.

I know i can create redirects to files as such:

exec 4>/tmp/lava
print "This will be saved to /tmp/lava and not screen"; >&4
print "This will be seen on screen" >&2

I want to save the STDOUT of a command to a variable and save STDERR to another without having to have files everywhere.

e.g tapelist=$( command blah blah )

I then want to check if tapelist contains anything and run stuff otherwise dont
i.e

if [[ -n "{tapelist}" ]];then
do stuff....
else
do other stuff
fi

If the command fails it produces STDERR output i want to save so i can print it out later.

So in my thoughts although i know this doesnt work :-

savestderr="";
exec 3>${savestderr}
tapelist=$(command blah blah 2>&3)

Then can reference the error message as ${savestderr} Any ideas?

Last edited by lavascript; 04-17-2009 at 08:38 AM.. Reason: whats wrong with the formatting?
 

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 12:49 AM.


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