I'm trying to execute a shell script from within my plugin -- but it's not working.
The script works when executed manually, or from a normal cgi script but things choke when I try to do it from a LinksSQL plugin. Can anybody think of why this wouldn't work? Most of the script below is working, no errors or thrown back. Just the shell script call is failing....
Any help/opinions are greatly appreciated.
Thanks,
Mike
Here's the code...
# ==================================================================
# Plugins::Class_Detailed - Auto Generated Program Module
#
# Plugins::Class_Detailed
# Author : Michael Paler
# Version : 1
# Updated : Wed Jan 5 17:34:06 2005
#
# ==================================================================
#
package Plugins::Class_Detailed;
# ==================================================================
use strict;
use GT::Base;
use GT::Plugins qw/STOP CONTINUE/;
use Links qw/$CFG $IN $DB/;
use File::Temp qw(tempfile);
use GT::Dumper;
# Inherit from base class for debug and error methods
@Plugins::Class_Detailed::ISA = qw(GT::Base);
# Your code begins here! Good Luck!
# PLUGIN HOOKS
# ===================================================================
sub build_detailed {
# -----------------------------------------------------------------------------
# This subroutine will be called whenever the hook 'build_detailed' is run. You
# should call GT::Plugins->action(STOP) if you don't want the regular
# 'build_detailed' code to run, otherwise the code will continue as normal.
#
my (@args) = @_;
# block of variables that we are encoding
my %vars = (
"cmd" => "_xclick",
"quantity" => "4",
"business" => "foo\@bar.com",
"item_name" => "Stuff I'm selling",
"amount" => "9.00",
"cancel_return" => "http://foo.com",
"currency_code" => "USD",
"rm" => "2",
"cert_id"=> "DPPL2XXXXXXXX"
);
# now use it to encrypt some text
my $str;
foreach my $var (keys(%vars)) {
$str .= "$var=$vars{$var}\n";
}
my $dir = "/private/classifieds/encrypt/";
my ($fh,$filename) = tempfile(DIR => $dir, SUFFIX => ".txt");
open($fh, "> $filename" )
or die "Can't create temp file: $1\n";
print $fh $str; # <-- this step is working because I can see $str in the temp file
my $encrypt = `/private/classifieds/encrypt/encrypt.sh $filename`; # <-- this step returns nothing...
#close($fh);
#unlink($filename);
# push the encryption into the $args hash
$args[0]{encrypt} = $encrypt;
# Do something useful here
print $IN->header;
print $str;
print $encrypt;
print Dumper(\@args);
GT::Plugins->action(STOP);
return @args;
}
# Always end with a 1.
1;
The shell script...
#!/bin/bash
MY_CERT=my-pubcert.pem
MY_KEY=my-prvkey.pem
MY_TEMP=$1
#while read line
#do
#echo $line
#done < $1
#echo $MY_TEMP
openssl smime -sign -in $MY_TEMP -signer $MY_CERT -inkey $MY_KEY -outform der -nodetach -binary | \
openssl smime -encrypt -des3 -binary -outform pem paypal_sandbox_cert.pem
The script works when executed manually, or from a normal cgi script but things choke when I try to do it from a LinksSQL plugin. Can anybody think of why this wouldn't work? Most of the script below is working, no errors or thrown back. Just the shell script call is failing....
Any help/opinions are greatly appreciated.
Thanks,
Mike
Here's the code...
# ==================================================================
# Plugins::Class_Detailed - Auto Generated Program Module
#
# Plugins::Class_Detailed
# Author : Michael Paler
# Version : 1
# Updated : Wed Jan 5 17:34:06 2005
#
# ==================================================================
#
package Plugins::Class_Detailed;
# ==================================================================
use strict;
use GT::Base;
use GT::Plugins qw/STOP CONTINUE/;
use Links qw/$CFG $IN $DB/;
use File::Temp qw(tempfile);
use GT::Dumper;
# Inherit from base class for debug and error methods
@Plugins::Class_Detailed::ISA = qw(GT::Base);
# Your code begins here! Good Luck!
# PLUGIN HOOKS
# ===================================================================
sub build_detailed {
# -----------------------------------------------------------------------------
# This subroutine will be called whenever the hook 'build_detailed' is run. You
# should call GT::Plugins->action(STOP) if you don't want the regular
# 'build_detailed' code to run, otherwise the code will continue as normal.
#
my (@args) = @_;
# block of variables that we are encoding
my %vars = (
"cmd" => "_xclick",
"quantity" => "4",
"business" => "foo\@bar.com",
"item_name" => "Stuff I'm selling",
"amount" => "9.00",
"cancel_return" => "http://foo.com",
"currency_code" => "USD",
"rm" => "2",
"cert_id"=> "DPPL2XXXXXXXX"
);
# now use it to encrypt some text
my $str;
foreach my $var (keys(%vars)) {
$str .= "$var=$vars{$var}\n";
}
my $dir = "/private/classifieds/encrypt/";
my ($fh,$filename) = tempfile(DIR => $dir, SUFFIX => ".txt");
open($fh, "> $filename" )
or die "Can't create temp file: $1\n";
print $fh $str; # <-- this step is working because I can see $str in the temp file
my $encrypt = `/private/classifieds/encrypt/encrypt.sh $filename`; # <-- this step returns nothing...
#close($fh);
#unlink($filename);
# push the encryption into the $args hash
$args[0]{encrypt} = $encrypt;
# Do something useful here
print $IN->header;
print $str;
print $encrypt;
print Dumper(\@args);
GT::Plugins->action(STOP);
return @args;
}
# Always end with a 1.
1;
The shell script...
#!/bin/bash
MY_CERT=my-pubcert.pem
MY_KEY=my-prvkey.pem
MY_TEMP=$1
#while read line
#do
#echo $line
#done < $1
#echo $MY_TEMP
openssl smime -sign -in $MY_TEMP -signer $MY_CERT -inkey $MY_KEY -outform der -nodetach -binary | \
openssl smime -encrypt -des3 -binary -outform pem paypal_sandbox_cert.pem