The UNIX and Linux Forums  

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
mail: no space for temp file usernamea UNIX and Linux Applications 3 10-02-2008 02:58 PM
Script to Delete temp files and check file system Bwood1377 Shell Programming and Scripting 3 08-14-2008 09:34 AM
Append to end of each line of file without a temp file. rorey_breaker Shell Programming and Scripting 4 04-03-2008 11:11 AM
Avoid Duplicates in a file pssandeep UNIX for Dummies Questions & Answers 7 03-26-2008 06:36 AM
Probably an easy SMIT question- "Unable to open temp file" jeffpas AIX 6 02-29-2008 06:06 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 10-24-2008
fox1212 fox1212 is offline
Registered User
  
 

Join Date: Oct 2008
Posts: 3
How to avoid a temp file

Hi all.

I want to check the free space on a given FS and process the output. Right now, I'm using a temp file to avoid using df twice. This is what I'm doing


#!/usr/bin/ksh
...
df -k $FS_NAME > $TMP_FILE 2>&1
if [[ $? -ne 0 ]]; then
RESULT="CRITICAL - $(cat $TMP_FILE)"
else
cat $TMP_FILE | ...
fi
rm $TMP_FILE


So, I store the result in a temp file, with the advantage of being able to store both sysout and syserr results I can later use as an output to the script. However, I don't like having to use a temp file.

So, is there some way to do the same without the temp file? Basically I want to:
  • Identify an error result from df (I'm using $? right now)
  • Get syserr output (I'm using 2>&1 now)
  • Process the resulting output.

If I just use a variable, as in A=$(...), I can't get the syserr, and I lose the carriage returns. Any ideas?

Thank you.
 

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 07:43 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