Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to automatically overwrite the output file when running `gpg` (i.e. without being prompted)? [closed]

Tags:

gnupg

If I have the same filename in the target directory, decryption fails.

The command I'm using to decrypt:

gpg --passphrase-fd 0 -o D:/Notification/mytest.txt --batch \
  --passphrase-file D:/passphrase.txt -d D:/Notification/mytest.gpg

It doesn't overwrite the mytest.txt file so each time I need to delete the file before I execute the script.

Is there any option to overwrite the output fie?

like image 474
Rider Avatar asked Sep 22 '11 18:09

Rider


People also ask

What does GPG -- Dearmor do?

The GPG manual says that --enarmor and --dearmor "Pack or unpack an arbitrary input into/from an OpenPGP ASCII armor. This is a GnuPG extension to OpenPGP and in general not very useful." An arbitrary value?

How do I decrypt a GPG file?

To decrypt a message the option --decrypt is used. You need the private key to which the message was encrypted. Similar to the encryption process, the document to decrypt is input, and the decrypted result is output. blake% gpg --output doc --decrypt doc.

What is the difference between PGP and GPG?

“PGP” stands for “Pretty Good Privacy”; “GPG” stands for “Gnu Privacy Guard.” It was the original freeware copyrighted program; GPG is the re-write of PGP. The PGP uses the RSA algorithm and the IDEA encryption algorithm. GPG uses the NIST AES, Advanced Encryption Standard.


2 Answers

Adding --batch --yes

Example:

gpg --batch --yes -u [email protected] -r "[email protected]" \
  --output "OUTPUTFILENAME.xls.pgp" -a -s -e "FILE.xls"

Complete example with passphrase file:

gpg --batch --yes --passphrase-fd 0 -u [email protected] -r "[email protected]" \
  --output "OUTPUTFILENAME.xls.pgp" -a -s -e "FILE.xls"< \
  passphrase.txt
like image 56
Tanya K. Avatar answered Oct 16 '22 20:10

Tanya K.


Just add the --yes option to you command line. The --yes option assumes yes for most questions which gpg will prompt for.

Source: http://www.gnupg.org/gph/de/manual/r1023.html

like image 35
David Mills Avatar answered Oct 16 '22 18:10

David Mills