I'm very confused on what I need to do. I've looked at if, while, but I can't seem to visualize where in my current script to put the commands.
I'm looking to read a directory /ERD/iface/data/ocom/citi/idd because there will be multible files, but I need to process them one at a time. The Process is copy the file, encrypt the file, send the file, delete the file. How do I loop this? Thank you VERY much.
Code:
# Set local variables.SN=pgp_cfs_idd_encryptENCRYPT=enc_sig_CFS_IDDSEND=eapsend_cfs_idd_prodMSGDIR=/home/pgp/messages/CFSSAPDIRIN=/ERD/iface/data/ocom/citi/iddDIRDOUT=/home/pgp/CFSUSA/outgoing_files/decryptedDIREOUT=/home/pgp/CFSUSA/outgoing_files/encryptedFILEIN=decrypt* (all files are named decrypt_test_move_YYYYMMDD_HHMMSS)FILEOUT=test_cfs_citiiddFAILSCRIPT=Nothing# ONLY send mail and first cp lines need to change below this line. ## Error_Successmsg routine function.Operator_Error_Msg(){mail -s " $SN failed in $FAILSCRIPT " mdurette@*****.com </home/pgp/CFSUSA/notes/failcfs}Operator_Success_Msg(){echo " $SUCCESSMSG was successful "}START=0# Change to the $SAPDIRIN directory and copy the file from SAP to PGPif [ $START = 0 ]; thencd $SAPDIRINcp $FILEIN /home/pgp/CFSUSA/outgoing_files/decrypted/$FILEOUT > $MSGDIR/$SN 2>&1COPY=$?echo "The copy from SAP to PGP RC= $COPY" >> $MSGDIR/$SN 2>&1SUCCESSMSG=startOperator_Success_MsgelseFAILSCRIPT=startexit $STARTfi# If the copy was successful, encrypt the file.if [ $COPY = 0 ]; then/home/pgp/scripts/$ENCRYPT \$FILEIN \$FILEOUT > $MSGDIR/$SN 2>&1PGP=$?echo "The encrypting of the decrypt file RC= $PGP" >> $MSGDIR/$SN 2>&1SUCCESSMSG=step1_copyOperator_Success_MsgelseFAILSCRIPT=step1_copyOperator_Error_Msgexit $COPYfi# If encryption was successful, test if EDI server is up.if [ $PGP = 0 ]; then/etc/ping -c 1 ecprod >> $MSGDIR/$SN 2>&1PING=$?echo "The pinging of ECPROD server RC= $PING" >> $MSGDIR/$SN 2>&1SUCCESSMSG=step2_encryptOperator_Success_MsgelseFAILSCRIPT=step2_encryptOperator_Error_Msgexit $PGPfi# If encryption and ping was successful, send the file out.if [ $PING = 0 ]; then/usr/local/bin/$SEND >> $MSGDIR/$SN 2>&1SEND=$?echo "The encrypted file has been sent RC= $SEND" >> $MSGDIR/$SN 2>&1SUCCESSMSG=step3_pingOperator_Success_Msgmail -s "Script Citibank IDD File System" -c "mdurette@*****.com" \ops@*****.com</home/pgp/CFSUSA/notes/CFSIDDgoodelseFAILSCRIPT=step3_pingOperator_Error_Msgexit $PINGfi# If the send was successful, delete the SAP file, decrypted file encrypted file.if [ $SEND = 0 ]; thencd $DIRDOUTrm -f $FILEIN >> $MSGDIR/$SN 2>&1REMV2=$?cd $DIREOUTrm -f $FILEOUT.pgp >> $MSGDIR/$SN 2>&1REMV3=$?echo "The Decrypted RC= $REMV2 file and the Encrypted RC= $REMV3 file have been deleted. " >> $MSGDIR/$SN 2>&1SUCCESSMSG=step4_sendOperator_Success_MsgelseFAILSCRIPT=step4_sendOperator_Error_Msgexit $SENDfi# End of script.
Last edited by vgersh99; 08-24-2009 at 11:38 AM..
Reason: code tags, PLEASE!
I have a structure which contains n number of elements. For example:
stFruits : apple, grapes, strawberry, pear, kiwi, melon, papaya, mango, orange, sweetlime ..... etc
Now i have to write a for loop as follows:
int i;
int j;
j=stFruits.apple+stFruits.grapes+stFruits.pear+.... and so... (3 Replies)
Hi there, I am checking disk spaced used on a box
# df -k | grep dsk | awk {'print $3'}
2055463
20165785
18310202
32274406
I want to somehow add them up but am no quite sure how to do this in a loop. ...i.e
for n in 'df -k | grep dsk | awk {'print $3}'
do
<some adding... (1 Reply)
Hi there
If I run a 'swap -l' on my solaris box, i get
swapfile dev swaplo blocks free
/dev/dsk/c1t0d0s1 54,65 8 67119560 65655144
/dev/dsk/c1t0d0s2 54,65 8 33119522 32655122
I wanted to run a for loop adding up the totals of each column 4 , excluding the... (2 Replies)
Hi,
I need to generate the text name dynamically in for loop,
ex,
VAR_COPY_FILE1= file path 1
VAR_COPY_FILE2= file path 2
VAR_COPY_FILE3= file path 3
for i in 1 2 3
do
if
then
"do some process here"
fi
done (3 Replies)
The scenario is like this :
I need to read records from a file one by one and increment counter1, if a certain field matches with a number say "40"..the script should increment the counter2 and also extract a corresponding field from the same line and adding them one by one and redirecting the the... (5 Replies)
Hi Everyone:
My shell script creates multiple csv files (~30) in for loop. I want to compile (or merge) 3rd column from each (all) of these files to another file (in loop). Please help. Thanks. (3 Replies)
I have a script below that goes to the given directory and plays the newest powerpoint presentation via powerpoint viewer and wine.
So far it works perfectly but now Id like to add a while statement to essentially run find /ticker/powerpointshare -mmin -1 -type f -iname "*.ppt" and if it finds a... (9 Replies)
Dear Experts
I think this is possibly the easiest thing. but I am not able to solve:
I need comma to be added to end of each line echo'd. But does not want it to be added to last line.
I have a script which does some data analysis and creates a command as in below code snippet
for... (4 Replies)
Hello All,
I have file a.txt
I want to add a counter loop at the end of each line in a file
ill explain:
i have a site h**p://test.test=Elite#1
i want to add a a counter to the number at the end of the file, that it will be like this
urlLink//test.test=Elite#1
urlLink//test.test=Elite#2... (3 Replies)