Hi,
I am having a problem with a shell script. I am working in a solaris environment.
I am using PGP(Pretty Good Privacy) for encrytping a file. It works on a file(.npgp in this case) and makes an .asc file (ASCII armored file)
The situation is like this. A user logs into a web site and enters his log on information. This process creates a file (.npgp) on the Unix box.The naming convention of the file is USERNAME_DDMMYYHHMISS.npgp
Now my problem is that how can I make sure that when I access the .npgp file, I am accessing the one pertaining to the current user and also that I am not removing some other users .npgp file.
For instance, lets say a user TEST logs at 11:45:51 PM. This process would create a file called TEST_090402114551.npgp
Lets say another user logs at 11:45:52 PM.This process would create a file called TEST_090402114552.npgp
Now I dont want that when the pgp command runs and when I remove the .npgp file the second file also gets removed.
The following shell script keeps on running in the background.
#!/bin/ksh
OUTDIR="/u02/file_out1"
OUTLOG="$OUTDIR/hotspot.log"
export OUTDIR
export OUTLOG
while true
do
#Check for the existence of a .npgp file.
if [ -e $OUTDIR/.npgp ]
then
#If it is there, run the following PGP command and remove it.
# Currently it will remove all the .npgp files.
pgp -eat +force *.npgp 2>$OUTLOG
rm -f *.npgp
fi
sleep 1
done
exit 0
What would be good is that if somehow I store the .npgp file name in a variable and remove only that file. Also that if a number of .npgp files in this directory, this command is run one by one for each .npgp file before deleteing that file?
Any help or suggestions would be greatly appreciated?