Sponsored Content
Top Forums Shell Programming and Scripting Formatting The Output Files & Matching Keys Post 302921846 by Ariean on Monday 20th of October 2014 02:01:48 PM
Old 10-20-2014
Formatting The Output Files & Matching Keys

I have the following 2 output files, one contain the standard output after i decrypt the encrypted file and another keys listed from the gpg trust db,

Provider File:
Code:
gpg: encrypted with 2048-bit RSA key, ID 96301328, created 2014-04-29
      "JKL <400@abc.com>"
gpg: encrypted with 2048-bit ELG-E key, ID ECB614CF, created 2002-02-06
      "GHI <300@abc.com>"
gpg: encrypted with 2048-bit ELG-E key, ID 1EB07C50, created 2014-02-20
      "ABC <100@abc.com>"
gpg: WARNING: message was not integrity protected


GPG Public Keys:
Code:
pub   1024D/17CD2890 2014-02-20
uid                  ABC <100@abc.com>
sub   2048g/1EB07C50 2014-02-20

pub   2048D/8911CBCA 2014-04-03
uid                  DEF <200@abc.com>
sub   2048g/F0E4D9C3 2014-04-03

pub   1024D/CB26F4C3 2002-02-06
uid                  GHI <300@abc.com>
sub   2048g/ECB614CF 2002-02-06

pub   2048R/547A8D75 2014-04-29
uid                  JKL <400@abc.com>
sub   2048R/96301328 2014-04-29

My requirements
1) After i decrypt the file i need to make sure there are three keys embedded or used to encrypt the file, i have to get the count from the file decryption output as shown in "Provider File" excerpt above.
2) I have to search for appropriate UID's and take the corresponding values 96301328,ECB614CF,1EB07C50 from "Provider File" and match those values with "GPG Public Keys" file and email out which key is different and associated email id.

For 1, i have following snippet awk -F"[<>]" '/@/ {L++ ; print $2} END{print L+0}' from a friend but how do i supress the email id's and just print only count?
For 2, I am still working on it?

Appreciate your inputs please help.

Last edited by Ariean; 10-20-2014 at 03:09 PM..
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

formatting output

my script is as follows cnt=`ps -ef |grep pmon|grep -v grep|awk 'END {{print NR}}'` cnt2=`ps -ef |grep tns|grep -v grep|awk 'END {{print NR}}'` if then if then rman target/ catalog recdb/recdb@recdb cmdfile report_need_backup.sql > report_need_backup.txt ... (1 Reply)
Discussion started by: swkambli
1 Replies

2. Shell Programming and Scripting

Output formatting

I have input file in this way John 1234 BASIC 26000 John 1234 ALLOWC 01550 John 1234 INCER 01700 John 1234 REL 20000 Debi 2345 BASIC 29000 Debi 2345 ALLOWC 01600 Debi 2345 INCR 01900 Debi 2345 REL ... (8 Replies)
Discussion started by: vakharia Mahesh
8 Replies

3. Shell Programming and Scripting

Output formatting .

below is a CPU utilization Log for ABC server. However for every 15 minutes it generates 3 CPU values(with interval of 2 sec). Host CPU CPUtotal CPU% time ABC 101.1 2 50.55 14 : 15 ABC 100.5 2 50.25 14 : 15 ABC 100.2 2 50.1 14 : 15 ABC 100.9 2 50.45 14 : 30 ABC 100.5 2 50.25 14 : 30 ABC... (5 Replies)
Discussion started by: pinga123
5 Replies

4. Shell Programming and Scripting

Problem with call of Java Programm & return code handling & output to several streams.

Hello Everybody, thanks in advance for spending some time in my problem. My problem is this: I want to call a java-Programm out of my shell skript, check if die return code is right, and split the output to the normal output and into a file. The following code doesn't work right, because in... (2 Replies)
Discussion started by: danifunny
2 Replies

5. Shell Programming and Scripting

How to combine 2 files and output the unique & difference?

Hi Guys, I have two input files and I want to combine them and get the unique values and differences and put them into one file. See below desired output file. Inputfile1: 1111111 2222222 3333333 7860068 7860069 7860071 7860072 Inputfile2: 4444444 (4 Replies)
Discussion started by: pinpe
4 Replies

6. UNIX for Dummies Questions & Answers

Formatting df output

Hi all, Can anyone please suggest how best to handle output from running df where some of the information for a volume/filesystem spread over two lines? Some of my volume/filesytem are NFS mounted and when I run a df, the information is spread over the two lines instead of the usual norm... (4 Replies)
Discussion started by: newbie_01
4 Replies

7. Shell Programming and Scripting

awk help: Match data fields from 2 files & output results from both into 1 file

I need to take 2 input files and create 1 output based on matches from each file. I am looking to match field #1 in both files (Userid) and create an output file that will be a combination of fields from both file1 and file2 if there are any differences in the fields 2,3,4,5,or 6. Below is an... (5 Replies)
Discussion started by: ambroze
5 Replies

8. Shell Programming and Scripting

Formatting output

I have the output like below: DEV#: 9 DEVICE NAME: hdisk9 TYPE: 1750500 ALGORITHM: Load Balance SERIAL: 68173531021 ========================================================================== Path# Adapter/Path Name State Mode Select Errors 0 ... (4 Replies)
Discussion started by: Daniel Gate
4 Replies

9. Shell Programming and Scripting

If && command giving wrong output

Hi All, I am trying to run a script which will search for 2 strings(stopped,started) in a text file and echo an output depending on below condition -bash-3.2$ cat trial1.txt v ggg f -bash-3.2$ cat trial1.sh VAR9=` grep 'stopped' /tmp/trial1.txt` VAR10=` grep 'started'... (4 Replies)
Discussion started by: srkmish
4 Replies
GnuPG(3pm)						User Contributed Perl Documentation						GnuPG(3pm)

NAME
GnuPG - Perl module interface to the GNU Privacy Guard (v1.x.x series) SYNOPSIS
use GnuPG qw( :algo ); my $gpg = new GnuPG(); $gpg->encrypt( plaintext => "file.txt", output => "file.gpg", armor => 1, sign => 1, passphrase => $secret ); $gpg->decrypt( ciphertext => "file.gpg", output => "file.txt" ); $gpg->clearsign( plaintext => "file.txt", output => "file.txt.asc", passphrase => $secret, armor => 1, ); $gpg->verify( signature => "file.txt.asc", file => "file.txt" ); $gpg->gen_key( name => "Joe Blow", comment => "My GnuPG key", passphrase => $secret, ); DESCRIPTION
GnuPG is a perl interface to the GNU Privacy Guard. It uses the shared memory coprocess interface that gpg provides for its wrappers. It tries its best to map the interactive interface of the gpg to a more programmatic model. API OVERVIEW
The API is accessed through methods on a GnuPG object which is a wrapper around the gpg program. All methods takes their argument using named parameters, and errors are returned by throwing an exception (using croak). If you wan't to catch errors you will have to use eval. When handed in a file handle for input or output parameters on many of the functions, the API attempts to tie that handle to STDIN and STDOUT. In certain persistent environments (particularly a web environment), this will not work. This problem can be avoided by passing in file names to all relevant parameters rather than a Perl file handle. There is also a tied file handle interface which you may find more convenient for encryption and decryption. See GnuPG::Tie(3) for details. CONSTRUCTOR
new ( [params] ) You create a new GnuPG wrapper object by invoking its new method. (How original !). The module will try to finds the gpg program in your path and will croak if it can't find it. Here are the parameters that it accepts : gnupg_path Path to the gpg program. options Path to the options file for gpg. If not specified, it will use the default one (usually ~/.gnupg/options). homedir Path to the gpg home directory. This is the directory that contains the default options file, the public and private key rings as well as the trust database. trace If this variable is set to true, gpg debugging output will be sent to stderr. Example: my $gpg = new GnuPG(); METHODS
gen_key( [params] ) This methods is used to create a new gpg key pair. The methods croaks if there is an error. It is a good idea to press random keys on the keyboard while running this methods because it consumes a lot of entropy from the computer. Here are the parameters it accepts : algo This is the algorithm use to create the key. Can be DSA_ELGAMAL, DSA, RSA_RSA or RSA. It defaults to DSA_ELGAMAL. To import those constant in your name space, use the :algo tag. size The size of the public key. Defaults to 1024. Cannot be less than 768 bits, and keys longer than 2048 are also discouraged. (You *DO* know that your monitor may be leaking sensitive information ;-). valid How long the key is valid. Defaults to 0 or never expire. name This is the only mandatory argument. This is the name that will used to construct the user id. email Optional email portion of the user id. comment Optional comment portion of the user id. passphrase The passphrase that will be used to encrypt the private key. Optional but strongly recommended. Example: $gpg->gen_key( algo => DSA_ELGAMAL, size => 1024, name => "My name" ); import_keys( [params] ) Import keys into the GnuPG private or public keyring. The method croaks if it encounters an error. It returns the number of keys imported. Parameters : keys Only parameter and mandatory. It can either be a filename or a reference to an array containing a list of files that will be imported. Example: $gpg->import_keys( keys => [ qw( key.pub key.sec ) ] ); export_keys( [params] ) Exports keys from the GnuPG keyrings. The method croaks if it encounters an error. Parameters : keys Optional argument that restricts the keys that will be exported. Can either be a user id or a reference to an array of userid that specifies the keys to be exported. If left unspecified, all keys will be exported. secret If this argument is to true, the secret keys rather than the public ones will be exported. all If this argument is set to true, all keys (even those that aren't OpenPGP compliant) will be exported. output This argument specifies where the keys will be exported. Can be either a file name or a reference to a file handle. If not specified, the keys will be exported to stdout. armor Set this parameter to true, if you want the exported keys to be ASCII armored. Example: $gpg->export_keys( armor => 1, output => "keyring.pub" ); encrypt( [params] ) This method is used to encrypt a message, either using assymetric or symmetric cryptography. The methods croaks if an error is encountered. Parameters: plaintext This argument specifies what to encrypt. It can be either a filename or a reference to a file handle. If left unspecified, STDIN will be encrypted. output This optional argument specifies where the ciphertext will be output. It can be either a file name or a reference to a file handle. If left unspecified, the ciphertext will be sent to STDOUT. armor If this parameter is set to true, the ciphertext will be ASCII armored. symmetric If this parameter is set to true, symmetric cryptography will be used to encrypt the message. You will need to provide a passphrase parameter. recipient If not using symmetric cryptography, you will have to provide this parameter. It should contains the userid of the intended recipient of the message. It will be used to look up the key to use to encrypt the message. The parameter can also take an array ref, if you want to encrypt the message for a group of recipients. sign If this parameter is set to true, the message will also be signed. You will probably have to use the passphrase parameter to unlock the private key used to sign message. This option is incompatible with the symmetric one. local-user This parameter is used to specified the private key that will be used to sign the message. If left unspecified, the default user will be used. This option only makes sense when using the sign option. passphrase This parameter contains either the secret passphrase for the symmetric algorithm or the passphrase that should be used to decrypt the private key. Example: $gpg->encrypt( plaintext => file.txt, output => "file.gpg", sign => 1, passphrase => $secret ); sign( [params] ) This method is used create a signature for a file or stream of data. This method croaks on errors. Parameters : plaintext This argument specifies what to sign. It can be either a filename or a reference to a file handle. If left unspecified, the data read on STDIN will be signed. output This optional argument specifies where the signature will be output. It can be either a file name or a reference to a file handle. If left unspecified, the signature will be sent to STDOUT. armor If this parameter is set to true, the signature will be ASCII armored. passphrase This parameter contains the secret that should be used to decrypt the private key. local-user This parameter is used to specified the private key that will be used to make the signature . If left unspecified, the default user will be used. detach-sign If set to true, a digest of the data will be signed rather than the whole file. Example: $gpg->sign( plaintext => "file.txt", output => "file.txt.asc", armor => 1, ); clearsign( [params] ) This methods clearsign a message. The output will contains the original message with a signature appended. It takes the same parameters as the sign method. verify( [params] ) This method verifies a signature against the signed message. The methods croaks if the signature is invalid or an error is encountered. If the signature is valid, it returns an hash with the signature parameters. Here are the method's parameters : signature If the message and the signature are in the same file (i.e. a clearsigned message), this parameter can be either a file name or a reference to a file handle. If the signature doesn't follows the message, than it must be the name of the file that contains the signature. file This is a file name or a reference to an array of file names that contains the signed data. When the signature is valid, here are the elements of the hash that is returned by the method : sigid The signature id. This can be used to protect against replay attack. date The data at which the signature has been made. timestamp The epoch timestamp of the signature. keyid The key id used to make the signature. user The userid of the signer. fingerprint The fingerprint of the signature. trust The trust value of the public key of the signer. Those are values that can be imported in your namespace with the :trust tag. They are (TRUST_UNDEFINED, TRUST_NEVER, TRUST_MARGINAL, TRUST_FULLY, TRUST_ULTIMATE). Example : my $sig = $gpg->verify( signature => "file.txt.asc", file => "file.txt" ); decrypt( [params] ) This method decrypts an encrypted message. It croaks, if there is an error while decrypting the message. If the message was signed, this method also verifies the signature. If decryption is sucessful, the method either returns the valid signature parameters if present, or true. Method parameters : ciphertext This optional parameter contains either the name of the file containing the ciphertext or a reference to a file handle containing the ciphertext. If not present, STDIN will be decrypted. output This optional parameter determines where the plaintext will be stored. It can be either a file name or a reference to a file handle. If left unspecified, the plaintext will be sent to STDOUT. symmetric This should be set to true, if the message is encrypted using symmetric cryptography. passphrase The passphrase that should be used to decrypt the message (in the case of a message encrypted using a symmetric cipher) or the secret that will unlock the private key that should be used to decrypt the message. Example: $gpg->decrypt( ciphertext => "file.gpg", output => "file.txt" passphrase => $secret ); BUGS AND LIMITATIONS
This module doesn't work (yet) with the v2 branch of GnuPG. AUTHOR
Francis J. Lacoste <francis.lacoste@Contre.COM> COPYRIGHT
Copyright (c) 1999,2000 iNsu Innovations. Inc. Copyright (c) 2001 Francis J. Lacoste This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. SEE ALSO
GnuPG::Tie Alternative module: GnuPG::Interface gpg(1) perl v5.14.2 2012-04-15 GnuPG(3pm)
All times are GMT -4. The time now is 08:29 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy