cannot open /dev/tty: No such device or address

Steve Butler sbutler at
Wed Oct 29 13:45:03 CET 2003

There is a similar error message when driving gpg from cron.  Try the
--no-tty option.

-----Original Message-----
From: Asier Urrutia [mailto:asier at]
Sent: Wednesday, October 29, 2003 1:00 PM
To: gnupg-users at
Subject: gpg:cannot open /dev/tty: No such device or address

Hi all,

	I've built a perl script in order to parse a mailbox, save
attachments from emails and decrypt them. If I run the perl script from a

bash$ cat mailbox |
Reading passphrase from file descriptor 11

You need a passphrase to unlock the secret key for
user: "GPG user (GPG user's key) <gpg-user at>"
1024-bit ELG-E key, ID D49D1DBC, created 2003-10-28 (main key ID 7724AA8E)
bash$ works fine. However, I am unable to get rid of the gpg
passphrase output. I tried to redirect STDOUT to a log file, but doesn't
make any difference.

	The main problem is when I pipe mail to this perl script from

bash$ cat .procmailrc
:0 HB : user.procmail.lock
* ^To:.*user at localhost.localdomain
| /home/user/bin/

	then, the script doesn't work due to the following error msg:

gpg: Warning: using insecure memory!
gpg: cannot open /dev/tty: No such device or address

	which looks to me that the gpg passphrase output is being sent to 
a terminal, but can't be found any and it fails. I'll enclose here the 
subroutine I'm using on the decryption, just in case somebody wants to 
know what I'm doing...

sub decrypting

  my $attachment  = $_[0];

  my $gnupg = GnuPG::Interface->new();

  $gnupg->options->hash_init( armor    => 1,
                              recipients => [ 'tj-cl-testing at' ]

  my ( $input, $output, $error, $passphrase_fh, $status_fh )
    = ( IO::Handle->new(),

  my $handles = GnuPG::Handles->new( stdin      => $input,
                                     stdout     => $output,
                                     stderr     => $error,
                                     passphrase => $passphrase_fh,
                                     status     => $status_fh,

  my $cipher_file = IO::File->new( "$attachment" );
  my $pid = $gnupg->decrypt( handles => $handles );

  print $passphrase_fh $passphrase;
  close $passphrase_fh;
  print $input $_ while <$cipher_file>;
  close $input;
  close $cipher_file;

  my @plaintext    = <$output>;   # reading the output
  my @error_output = <$error>;    # reading the error
  my @status_info  = <$status_fh>; # read the status info

  my $date = `date`;
  print LOGFILE "\n$date -- $attachment decryption 
  print LOGFILE @error_output;
  print LOGFILE @status_info;

open (SAVE,">$ATTACHLOC/$ATTACHMENT.decrypted");
print SAVE @plaintext;
  # clean up...
  close $output;
  close $error;
  close $status_fh;

  waitpid $pid, 0;  # clean up the finished GnuPG process


	Anybody came across something like this?

Thanks a million,

Gnupg-users mailing list
Gnupg-users at

CONFIDENTIALITY NOTICE:  This e-mail message, including any attachments, is for the sole use of the intended recipient(s) and may contain confidential and privileged information.  Any unauthorized review, use, disclosure or distribution is prohibited.  If you are not the intended recipient, please contact the sender by reply e-mail and destroy all copies of the original message.

More information about the Gnupg-users mailing list