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
Debian: New policyd-weight packages fix insecure temporary files iBot Security Advisories (RSS) 0 03-27-2008 02:50 PM
remove temporary file ? varungupta Shell Programming and Scripting 5 11-23-2007 03:50 AM
Avoid creating temporary files on editing a file in Ubuntu royalibrahim Ubuntu 7 11-17-2007 05:57 AM
Removing temporary alias veccinho AIX 1 09-04-2007 05:19 AM
solve temporary root password go3mon Shell Programming and Scripting 1 06-23-2005 08:09 AM

Closed Thread
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
  #1 (permalink)  
Old 09-18-2008
gio001 gio001 is offline
Registered User
  
 

Join Date: Mar 2007
Posts: 70
Temporary files and rm

Hello everyone,
I am creating a temporary file in my ksh by using something file
filetemp=filetemp.$$
Later on in my script I write to the file $filetemp by 'cat'ing to it.
Then in the script I am doing a 'less' on the file to view it.
At the end of the script I issue a rm $filetemp 2> /dev/null .
I am experiencing an issue that I would like to have explained.
Most of the times the file is deleted properly. Once in a while, though, the file is still there after I exit my script.
I cannot tell if it is related to the file being large or small or if it is tied to the amount of time the file stays open under the 'less' command.
Any ideas?
Maybe there is a better way to deal with temp files?
Any suggestions or advice will be greatly appreciated.
Thanks.
  #2 (permalink)  
Old 09-18-2008
gurukottur gurukottur is offline
Registered User
  
 

Join Date: Apr 2006
Posts: 40
u can always use mktemp to create temp files

and to delete the file at the end

just do

trap '/bin/rm -f $file' 0 1 3
  #3 (permalink)  
Old 09-18-2008
gio001 gio001 is offline
Registered User
  
 

Join Date: Mar 2007
Posts: 70
No mktemp ...

I do not seem to have mktemp on AIX.
  #4 (permalink)  
Old 09-18-2008
SFNYC SFNYC is offline
Registered User
  
 

Join Date: Jun 2008
Location: New York City
Posts: 95
Well, the first thing you should do is change 'rm $filetemp 2> /dev/null' to 'rm $filetemp 2> somefile' so you can capture the error message and interrogate what rm is producing in order to find out why it is not removing the file. This may give you a clue as to what is happenning.

Sam
  #5 (permalink)  
Old 09-18-2008
broli's Avatar
broli broli is offline
Registered User
  
 

Join Date: Dec 2007
Location: Argentina
Posts: 215
maybe your script is receiving some kind of kill signal and dieng before the rm
Closed Thread

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 02:05 PM.


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