gpg return value problem

Jeff Fisher jeff+gnupg at jeffenstein.dyndns.org
Fri Jan 28 08:48:42 CET 2005


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

On Thu, Jan 27, 2005 at 10:00:26AM -0800, Mark Ivs wrote:
> Hello,
> I am trying to capture the return value from the gpg
> command. Documentation says, gpg will return 0 if
> successful or return 1 if there's an error.
> 
> $errorval = 0;
> $errorval = 'gpg --recipient "XXX" --output
> $rootpath\\output\\$filepgp --encrypt
> $rootpath\\encrypted\\$file';
> 

It looks like you're doing this in perl, so it's a bit off-topic for the list,
but...

This will only catch the output:
$output = `cmd`; 

What you want to do is to check the $? variable after running the command,
like this:
$output = `cmd`;
if( $? ){
    print "gpg returned: $?\n";
    # error handling
}

You'll probably want to look at 'perldoc -f system' on what to do with $? to get
meaningful information.


- -- 
jeff at jeffenstein.org                  http://www.jeffenstein.org/
"Men occasionally stumble on the truth, but most of them pick themselves up
and hurry off as if nothing had happened." - Winston Churchill
-----BEGIN PGP SIGNATURE-----

iQIVAwUBQfnuWhwPMBUZyYf1AQiXwRAArTHQSUjaLCVtuiqGZcTNqEMgv198ljMq
D964bBSH7tvW0q52MMPxaY43JEaGO8pX3wVM8mpymuaGaSixSK1c5M+xEklZpt9f
GNxgxKKhHJ6GBxqX+Yehcyu6nBrDN41kZxJvllZNXo7EgRqRzM3P2YV4+7Zm+XO+
4eTseVcSi4nWbH6RQzoXGCS0V5QsAMow7FPVlVpe3/xN5iW/eu1mJKihNL/X8uSZ
F/Woi1QyIk04RR6ZH9S2jxU3HI5OzgzrmwAgCgwvVRVQl9mq8gQH3S7gSZ4B9gnx
FiHb4Tlgc16R6DUU7AI+Y8DNFKAX0jx0BTsJrWwe9CZQ6OJdZYyYTaxcgPuTqmkY
I3J7h6nQgTuMQPEPsfQaAMdN9SdD+vknB2J620ateZLpXxo/pdihNAeJvt4yFKco
VLk92hqATnDMMp0suWGL243FKkXPr/zjmhYieefJjumWWjkz8t2pS7rJsJNc1QOQ
L2brL8ImiiAYWgtDP1kI+ym8HORSBEM0EU0ieLVd6wpL4Jjouw7duB8fsryyjn5Q
xEAimX7WD/ksNy+mDfAtgaDMkHjnftTXJKCjumDoXuAyPH4wqin0s+DAhvWgAeHo
ru6/R5HKtBUnPShUNPHISgAHlTqxeYx4ikj33dMrQSlBINJIIbp/CjlAB9YJbD38
+McIv8apsfw=
=NA/V
-----END PGP SIGNATURE-----



More information about the Gnupg-users mailing list