dealing with password in batch file

Trevor Smith trevor at
Sat Apr 22 03:44:15 CEST 2006

On 21-Apr-06, at 3:11 PM, Sean Cerney wrote:
> I've been decrypting xml files for a while now with a batch file  
> that converts the pgp file into an xml file with a timestamp.
> The thing is I always have to manually enter the password each time  
> I run the batch file.  I want to
> ...
> Any suggestions?  Thank you.

Sorry, I'm not 100% sure what you're trying to do (I couldn't see any  
actual gpg stuff in your batch file, but it's been about a hundred  
years since I've seen a .bat file so I could be missing the  
obvious...), but if you're trying to automate passphrase entry into a  
batch file, here is what I have used in a Unix (or, rather, Linux and  
Mac OS X, actually) bash shell script:

gpg --passphrase-fd 3 "$FILE" 3<$pwfile

where $FILE is the file to be decrypted and $pwfile is a variable  
that is set to some arbitrary file name that contains the passphrase.

What the above does is (after you create a temporary file with the  
passphrase in it) tell gpg to read the passphrase from "file  
descriptor 3" and the last bit (3<$pwfile) tells Unix to redirect the  
file, $pwfile, into file descriptor 3.

Obviously you need to modify this somewhat to run on DOS (or Windows,  
or whatever it's called these days) but it may point you in the right  

Trevor Smith
trevor at

More information about the Gnupg-users mailing list