![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| 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 |
| Problem In Shell Script | satyakide | Shell Programming and Scripting | 11 | 09-24-2007 11:00 AM |
| Help! Problem with Shell Script. | pektl | Shell Programming and Scripting | 7 | 05-29-2006 06:08 AM |
| Problem with SU or SSH in shell script | sravanp | UNIX for Dummies Questions & Answers | 2 | 01-24-2006 12:00 PM |
| Shell Script problem | bnohifi | Shell Programming and Scripting | 1 | 07-07-2005 03:02 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
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? |
|
||||
|
Hi there. If I understand your question correctly, I would use a "for" loop for this.
Check the for man page, but it would go something like this: for namevariable in *.npgp do actions # for example, rm $variable done |
|
||||
|
natty, I believe the for-loop provided by kristy is the answer you seek. It provides all the filenames, one by one, into the specified variable name for processing on each loop: Code:
for fname in *.npgp do echo "Processing $fname ..." done |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|