0

I have been trying to replicate what has been suggested by Bruno Braga at the end of this thread: How do I encrypt/decrypt file within gedit?

I copied these two scripts and followed the instructions to the letter. But I had no joy as I get the 512 error. It says gpg: Sorry, no terminal at all requested - can't get input.

The only thing I have changed is my email in the Encrypt script:

#!/bin/bash
stdin=$(cat)

if [ ! "${stdin:0:27}" == "-----BEGIN PGP MESSAGE-----"  ]; then 
     echo "$stdin" |   gpg -a -e -r elmclose@gmail.com --no-tty  -
else
    echo "$stdin"
fi


#!/bin/bash
stdin=$(cat)

if [ "${stdin:0:27}" == "-----BEGIN PGP MESSAGE-----"  ]; then 
    echo "$stdin" | gpg -d --no-tty - 2> /dev/null
else
    echo "$stdin"
fi

I have tested the command:

gpg -a -e -r elmclose@gmail.com test.txt

at the terminal and it works fine. I have set the Input to "current document" and the output to "Replace current document"

What am I doing wrong?

I couldn't leave a comment at that thread as I have not enough reputation.

1

The email address is not the only thing you modified. You also changed the shell from Bash to Bourne in the shebang:

#!/bin/sh

Change it to this:

#!/bin/bash

The Bourne Shell doesn't support fancy Bash parameter substitutions like this: "${stdin:0:27}"

  • I changed /sh to /bash and got this message: gpg: 873E6BFC: There is no assurance this key belongs to the named user gpg: Sorry, no terminal at all requested - can't get input and when I removed --no-tty the second message become: gpg: cannot open tty `/dev/tty': No such device or address In terminal mode I get the first message and I usually type yes and it finishes the job. But here it cannot receive an answer and drops out. Is there a way I can supply the answer "yes" as part of the script? or is there something else wrong with my script? – elmclose Sep 4 '16 at 22:19
  • I don't know about GPG. You should update your question with the new info. – wjandrea Sep 4 '16 at 22:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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