LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-27-2014, 10:19 PM   #1
mitchellfox
LQ Newbie
 
Registered: May 2010
Posts: 5

Rep: Reputation: 0
need help with bash script


I need to write and use a bash script, probably simple for some users. I have never done it before but greatly need it. I have to process 100 files or so through the same command, each time giving it a different file to use as input and having it create a different file name for the output. So it would read a file form a directory, decrypt it using pgp, send the output with part of the same file name to a child directory, then go back and read the next one ,etc.
The command that will be processing is (gpg --batch --trust-mode always --passphrase-file /XXXXX-xxxx/xxxxxx/TEDKEYPASSFILE -r XXXXHPPGP -r GatewayServices --output /home/xxxxxx/xxxxxx/member_prod_XXXX_ABC_AF_12345678.xml --decrypt /XXXX-xxxprod/xxxxx/xxxxxx/xxxxxx/xxxxx/xxxxx_prod_xxxxxx_xxxxx_AF_12345678.xml.pgp.12345678

I could copy them out of their normal directory so that the iteration codl be based on the # of files in the directory it is reading from.
Thanks
 
Old 10-27-2014, 11:46 PM   #2
Tadaen
Member
 
Registered: Sep 2005
Distribution: Arch
Posts: 210

Rep: Reputation: 39
I know nothing about gpg or encryption. But if I'm understanding you a for loop would be the ticket here.

Code:
for file in /path/to/source/* # this can be followed with an extension - *.xml for all xml files and so forth
do
    decrypt "$file" > /path/to/destination/"$file".dc # dc = decrypted
done
As said I know absolutely nothing of how to structure a gpg command. But this is a general idea.

Last edited by Tadaen; 10-28-2014 at 12:07 AM.
 
Old 10-28-2014, 01:59 PM   #3
rtmistler
Moderator
 
Registered: Mar 2011
Location: Sutton, MA. USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu
Posts: 4,484
Blog Entries: 10

Rep: Reputation: 1643Reputation: 1643Reputation: 1643Reputation: 1643Reputation: 1643Reputation: 1643Reputation: 1643Reputation: 1643Reputation: 1643Reputation: 1643Reputation: 1643
Some guides, because what you need to do is start your attempt and then post further questions at points where you've tried something and then need further assistance. Merely stating the problem you want to solve and asking for help is impolite.

Bash Guide for Beginners
Advanced Bash Scripting Guide

Tadean has also given you some helpful advice.
 
1 members found this post helpful.
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Bash Script - Reading User Input while Processing output from Command within Bash cleeky Linux - General 5 05-27-2014 03:57 PM
How to end the bash script using commands in bash not manually by pressing ctrl+c Sanpreet Singh Linux - Newbie 1 07-03-2013 02:04 PM
[SOLVED] Converting Script from Linux (GNU) Bash 4 to Solaris Bash 2.05 - Any cheat sheet? oly_r Solaris / OpenSolaris 6 05-03-2013 09:25 AM
SSH connection from BASH script stops further BASH script commands tardis1 Linux - Newbie 3 12-06-2010 09:56 AM
[SOLVED] Using a long Bash command including single quotes and pipes in a Bash script antcore Linux - General 9 07-22-2009 12:10 PM


All times are GMT -5. The time now is 12:51 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration