Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have the following script:

#!/bin/sh -e
PWD="supersecretpassword"
file="/backup/2do/example.txt"
echo before
echo $PWD | gpg --passphrase-fd 0 -c $file
echo after

The scripts works perfectly fine if executed manually, but simply stops working when the gpg line is performed when performed as crontab.

GPG shows:

gpg: cannot open `/dev/tty': No such device or address

I'm grateful for any suggestions!

Solution: add --no-tty to GPG

share|improve this question
1  
$PWD is very bad choice for a variable. it is a shell variable... –  dfc Oct 18 '11 at 22:00
add comment

2 Answers

up vote 1 down vote accepted

Add -vv to the gpg command to see more output. It might have to do with a missing ~/.gnupg though.

share|improve this answer
    
Thank you, that pointed me into the right direction: --no-tty –  MrG Oct 14 '10 at 10:37
add comment

/usr/bin/gpg --no-tty --passphrase-file /home/vouuuuuuuuu/settings/passfile.txt --decrypt-files /home/juhuuu/dirname/*.gpg;

works fine now thank to --no-tty before in cron job log gpg: cannot open `/dev/tty': No such device or address so it could not execute before, now is fine!

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.