Pergunta

I'm using php to invoke gpg, but I'm getting a pipe error. I thought that if I read in the password from a file, I could then pipe it to the command itself? But, I keep getting: Syntax error: "|" unexpected

Here's the code:

(Note: The files are being iterated over in a foreach loop...)

foreach($files as $k => $v) {
    $encrypted = $v;
    $filename = explode('.',$v);
    $decrypted = $filename[0].'.txt';
    shell_exec("echo $passphrase | gpg --no-tty --passphrase-fd 0 -o $decrypted -d $encrypted");
}
Foi útil?

Solução

maybe you can print the lines instead and then run them in a terminal to see if they really work as expected. Maybe there is some weird character in your input that needs to be escaped, and please put your PHP variables in quotes, filenames with spaces could be dangerous. See escapeshellarg and escapeshellcmd.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top