Maybe you are trying to do something the hard way which is really easy.
You see,
expect is used when you start another program (like telnet), and you
expect something from that external program like
username:. The instead of you as human user enter this information, you let
expect send the information from your script to the external program (like telnet).
If I understand right, what you want to do is to prompt the user for a passphrase, read that passphrase from the user and run pgp with that information?
That would be something like this:
Code:
#!/bin/sh
echo -n "enter passphrase"
read pf
gpg --passphrase $pf -d file.txt.pgp > file_$d.txt
Please also refer to the Advanced Bash Scripting Guide, the link is in my signature.
Now take into account that I don't know exactly how to use gpg. If you want to start the gpg program from within your script, have gpg ask for a passphrase and let your scrip supply it, that is exactly how I described that in the second paragraph. You'd have to use
expect.
jlinkels