So I came across a minor issue here, and was hoping anyone could help me.
I'm on Unix SunOS, 5.10 as well as Linux 2.6.32
So everything I do has to work on both (fun ..)
Anyway, I have a few scripts, which handle some temporary files, I dropped in some basic trap commands in order to clean things up when it exits:
This (seems to) work fine, however, I run into a small issue when I call one script from the other
So I have the above code in 2 scripts, and in the first I call the 2nd. They each have their own temp file, both of which I want cleaned up when that particular script exits.
ie
and
However, I'm noticing the the file from script_1.ksh sticks around, and isn't being cleaned up. I'm assuming it's because of the similar declaration in script_2 is "clobbering" it ... however, I'm not 100% sure how to work around this?
I'm tempted to change the line:
to:
However, even if that works [edit] it doesn't - tried it - found confirmation that it's the subsequent trap clobbering the existing trap[/edit], I'm not sure that's the "correct" solution.
Jim, doesn't your quote rather mean a prefixed assignment like
?
--
For me this looks like bug. Running annother program, even another shell, should not obscure the current signals.
In Korn shell you might want to use "trap 0" to do end processing (such as removing temporary files). It is a virtual signal and the trap code is executed every time the script exits, regardless of how the exit is done.
In Korn shell you might want to use "trap 0" to do end processing (such as removing temporary files). It is a virtual signal and the trap code is executed every time the script exits, regardless of how the exit is done.
I hope this helps.
bakunin
Sorry, am I missing something?
I thought:
and
where essentially identical?
In anycase, wouldn't they both get nuked when I called the next shell anyway? (according to the docs?) [edit]correction: meant to imply when the next TRAP command is issued - within the next shell - sorry [/edit]
Sorry, I'm not sure what you're trying to say here that I haven't already tried?
Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!
1. The problem statement, all variables and given/known data:
That is the last reply I received from my instructor, and I'm looking for some alternatives.
When using... (2 Replies)
I have a server running redhat 5.5 and it has one SAN device presented to it as LUN9. How can I clean up the remaining entries. I cannot afford to interupt the service. Please assist.
# multipath -l
mpath0 (36000097000019260298953666633436) dm-11 EMC,SYMMETRIX
\_ round-robin 0
\_ 2:0:0:9 ... (2 Replies)
Hi,
I am trying to clean up data between parenthesis () in a file.
See example below....
Input File :
(New York) Chicago (London)
New York (Chicago) London
New York Chicago (London)
(New York) (Chicago) (London)
New York (Chicago)
... (3 Replies)
Hi All,
I have this script for linux on cleaning up orphaned folder. But I need to use this on solaris 8/9/10
for user in $(ls | grep -v lost+found) ; do
id $user >/dev/null 2>&1
if ]
then
ls -ld $user
grep $user /etc/passwd
fi
done
Can someone please convert this script? ... (1 Reply)
Hi folks,
I have tried to add some trap detection in the below script....this script is used to monitor database activities...in a rather awkward way :rolleyes:....
The idea behind adding trap is that....this script creates lots of temporary files in the running folder to store the count... (1 Reply)
Hi!
I would like to write a script which remove some files, all beginning with the same prefix :
prefix.1
doc/prefix.2
../prefix.3
etc.
So, I would create a file and chmod it executable. But I dont know how to pass a variable to a script. I would like to write something like
... (2 Replies)
I am trying to add a unique string to a variable to prevent some name space collisions.
DATAFILE=/u001/app/unica/affinium644/campaign/partitions/limited/tmp/ebf9aaah.t~#
DATETIME=`date +%Y%m%d_%H%M%S`
echo $DATAFILE > tmpnme.txt
sed 's_/_ _g' tmpnme.txt > tmpnme2.txt
DATA=$(cat tmpnme2.txt)... (2 Replies)
Hello
I have many old IDs on my AIX and would like to know the
simplest way of knowing the last time an ID was used.
I am familiar with the "last" command.
Thanks for any info :) (1 Reply)
Hello all,
I'm hoping to get a little insight from some of the wily veterans amongst you.
I've written a script to check for new outgoing files to our vendors located on our ssl server. It seems to be working ok, but the final question here, will be one of logic, and/or a better way to... (4 Replies)