Help with GPG Scripting and sending mail when done!!!


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Help with GPG Scripting and sending mail when done!!!
# 1  
Old 06-18-2008
Help with GPG Scripting and sending mail when done!!!

I am very new to linux so please explain things to me like I was not from this world. I never wanted to learn linux, but since the other IT person is gone, I was the only one left. So now I have been messing around with it alot, and I really like it. Bought a few books, and CBT's to get use to it, and I absolutely love it, though my games don't work, I can live without them for now.

Anyways, I am making a script to decrypt a file and then send an email when done. The thing is I want to keep this as close to automatically as possible. So the next person won't need to fuss about the long process of our loads.

So my first problem is displaying the files with certain credentials, then moving all previous files to a backup folder. Our clients sometimes sends us two files, but the latest one is the one we need to process. But I can not even get this program to display all the files.

Then after displaying it move the old files to backup and only have the newest file.

I have this so far:

#!bin/bash

# Check directory for all rabadd*.gpg
if [ -e /home/eacsci1/rabadd*.gpg ]; then
echo "rabadd encrypted file(s) exist"

# Locate and display files with name rabadd and ext .gpg. Then clear when done.
find -maxdepth 1 -name rabadd*.gpg > rabadd.txt ; cat rabadd.txt ; rm rabadd.txt.
# In case the encrypted file does not exist, let user know.
else
echo "rabadd encrypted file(s) not found!"

fi
# 2  
Old 06-18-2008
here is a start:
Code:
#!bin/bash

# Check directory for all rabadd*.gpg

filefound=$(ls /home/eacsci1/rabadd*.gpg > 2>&1 > /dev/null; echo $?)
if [ $filefound -eq 0 ]] ; then
   echo "rabadd encrypted file(s) exist"

# Locate and display files with name rabadd and ext .gpg. Then clear when done.

   find -maxdepth 1 -name rabadd*.gpg -exec ls -l {} \;

# In case the encrypted file does not exist, let user know.

else
   echo "rabadd encrypted file(s) not found!"
fi

# 3  
Old 06-18-2008
Ok I added the script you mention besides

Code:
[ $filefound -eq 0 ]]

I think this should only have one bracket, right?

Anyways it still produces an error message that I can not interpret

Code:
./prep_down.sh: command substitution: line 14: syntax error near unexpected token `2'
./prep_down.sh: command substitution: line 14: `ls /home/eacsci1/rabadd*.gpg > 2>&1 > /dev/null; echo $?'
./prep_down.sh: line 16: [: -eq: unary operator expected
rabadd encrypted file(s) not found!

I will change it up and get some understanding of this part, until someone can point out the issue here.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Red Hat

Problems sending mail: Difference between Mail and Mailx?

Whats the difference between mail and mailx? I'm trying to troubleshoot a problem where I can send mail from server A with this `echo $MESSAGE | mail -s "$SUBJECT" -r $FROM $RECIPIENTS` command but executing the same command from server B throws me this error (Both servers are RHEL) ... (1 Reply)
Discussion started by: RedSpyder
1 Replies

2. UNIX for Dummies Questions & Answers

Sending mail

How can i send a mail when user login in unix ENV. How can i know present use mailID?? Moved out of Contact Us Forum - Please Do Not Post Technical Questions in Non-Technical Forum(s) (1 Reply)
Discussion started by: arun508.gatike
1 Replies

3. Shell Programming and Scripting

Reading a file and sending mail by shell scripting?

hi I need help urgently...i need to write a shell script which can solve the following problem....its urgent plz help me out coz m totally newbie in shell scripting.... the problem is: Suppose I have a folder called logs. whenever some error occurs some correspondence error file is generated. I... (4 Replies)
Discussion started by: sukhdip
4 Replies

4. Shell Programming and Scripting

Sending Mail

Hi All, I have a script that looks like this: *********** #!/bin/sh -x cd /u01/app/oracle/diag/rdbms/spdb/spdb/trace cat alert_spdb.log|grep Archiver >/dev/null if ; then mailx -s "Archiver message in Alert log" user@email.com fi ************ Im using the -x option to see any... (1 Reply)
Discussion started by: oradba888
1 Replies

5. Shell Programming and Scripting

Stop sending mail after certain number of mail

Hi guys... I am busy writing a script to notify me via an mail if my application is down. I have done that. Now I want this script to stop sending mails after five mails were sent but the script should keep on checking the application. When the application is up again that count should be... (5 Replies)
Discussion started by: Phuti
5 Replies

6. UNIX for Dummies Questions & Answers

sending mail

i want to send an email from the unix machine to the windows machine. now windows dont have any specified folder for the mail. mail has to be sent to the email-id like abc@xyz.com unix machine itself can not directly send mail. it has to be transferred via mail server. (11 Replies)
Discussion started by: parmeet
11 Replies

7. Ubuntu

help sending mail

Hi, I have kubuntu 8.10 and I would like to configure Ubuntu to can send mail from command line with mailx. I've saw that I need to install a MTA. But I don't know with install and how. Do you know some howto or url where I find how could I configure it? Many thanks and sorry for my... (2 Replies)
Discussion started by: mierdatuti
2 Replies

8. HP-UX

Sending mail thru HP-UX

I got stuckup with the issue of sending mail with attachment from HP-UX. Can any one please help me in resolving the issue. I am giving the criteria which i want below, 1. To address. 2. Cc address. 3. Subject 4. File attachment(the file i am using is :-- filename_`date +%Y%m%d`.CSV)... (1 Reply)
Discussion started by: medisetti
1 Replies

9. UNIX for Dummies Questions & Answers

Sending Mail

Please help me out i want to know how to send email from unix machine to any email-id. mail to be sent is web based mail. (1 Reply)
Discussion started by: parmeet
1 Replies

10. UNIX for Dummies Questions & Answers

sending a mail to a mail client

Hi everyone! I'm trying to create a database monitoring script that reads an alert file and sends an error message if it can 'grep' a particular string. Is there a way to send this message to a mail client using SMTP? Even better, is there any place on this site that has these kinds of... (5 Replies)
Discussion started by: solaris73
5 Replies
Login or Register to Ask a Question