Re: echo problem when escaping gpg commands

From: Date: Tue, 20 Jun 2000 22:54:30 +0000
Subject: Re: echo problem when escaping gpg commands
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-2392@lists.php.net to get a copy of this message
In article <004201bfd72f$61cf3ef0$6c790fd8@orange>, Charles@AlcatrazDesignGroup.com ("Charles Killian") wrote: > I'm having difficulty piping input into the gpg command. The line below = > works because echo only has one line to output. > > $last_line =3D exec("echo \"blue\" | gpg -a -e ", $out_ary, $cmd_retun); > > As soon as I try to echo a variable that contains \n, echo only = > prints/pipes the first line. Therefore, the gpg command fails. > > $var =3D "big\n red\n herring\n"; > $last_line =3D exec("echo $var | gpg -a -e ", $out_ary, $cmd_retun); Both PHP and the shell use \ as the escape character, so keep adding \ until it works. \\n \\\n \\\\n \\\\\n ... Also, consider switching to popen() instead of exec() since "ps auxwwwww" will show your data that you're trying to keep secret... Search the mailing list archives for "gpg and popen" It's been done before. -- Richard Lynch | If this was worth $$$ to you, buy a CD US Customer Support Director | from one of the artists listed here: Zend Technologies USA | http://www.L-I-E.com/artists.htm http://www.zend.com | (this has nothing to do with Zend, duh!)

« previous php.general (#2392) next »