[prev in list] [next in list] [prev in thread] [next in thread] 

List:       gpg4win-users-en
Subject:    [Gpg4win-users-en] Help with ActivePerl and Task Scheduler - SOLVED
From:       Scott Stansbury <sstansbury () aol ! com>
Date:       2012-04-23 19:55:07
Message-ID: CB1952A9-EEC7-43D9-B087-AC79CBE7B08C () aol ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


The issue was that there was no path to gpg2.exe when running under Task Scheduler. \
And as Perl doesn't have access to the system environment variables (to the best of \
my limited knowledge), I wrapped the Perl script in a batch file wrapper:


@echo off
set perl_bindir=C:\Perl\bin
set PATH=%PATH%;"C:\Program Files (x86)\GNU\GnuPG\pub"

%perl_bindir%\perl.exe -x -S %0

goto endofperl

#!perl
BEGIN {
	use Win32 qw( SW_HIDE );
	Win32::SetChildShowWindow( SW_HIDE );
}

use strict;
use warnings;

my $log = "decrypt.log";

close ( STDOUT );
open ( STDOUT, ">>$log" );

close (STDERR );
open (STDERR, ">>$log" );

# The below are commented out as I am entering them directly on the command line for \
troubleshooting purposes.

# my $data_file = "TEST_FILE.txt.pgp";
# my $incoming_dir = "C:\\Users\\Public\\TEST\\Incoming";
# my $data = "C:\\Users\\Public\\TEST\\Incoming\\TEST_FILE.txt.pgp";
# my $output_file = $data_file;
# $output_file =~ s/\.pgp//;

# my $data_dir = "C:\\Users\\Public\\TEST\\Data";
# my $output = "C:\\Users\\Public\\TEST\\Data\\TEST_FILE.txt";

# my $sec_keyring = "C:\\Users\\Administrator\\AppData\\Roaming\\gnupg\\secring.gpg";
# my $pub_keyring = "C:\\Users\\Administrator\\AppData\\Roaming\\gnupg\\pubring.gpg";

system ( "gpg2.exe --batch --yes --passphrase-fd 0 --output \
C:\\Users\\Public\\TEST\\Data\\TEST_FILE.txt --no-default-keyring --keyring \
C:\\Users\\Administrator\\AppData\\Roaming\\gnupg\\pubring.gpg --secret-keyring  \
C:\\Users\\Administrator\\AppData\\Roaming\\gnupg\\secring.gpg \
--exit-on-status-write-error --decrypt \
C:\\Users\\Public\\TEST\\Incoming\\TEST_FILE.txt.pgp < passphrase.txt" );


__END__
> endofperl

Works fine. My regrets for the distraction...

Scott...




_______________________________________________
Gpg4win-users-en mailing list
Gpg4win-users-en@wald.intevation.org
http://lists.wald.intevation.org/cgi-bin/mailman/listinfo/gpg4win-users-en


[Attachment #5 (unknown)]

<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; \
-webkit-line-break: after-white-space; ">The issue was that there was no path to \
gpg2.exe when running under Task Scheduler. And as Perl doesn't have access to the \
system environment variables (to the best of my limited knowledge), I wrapped the \
Perl script in a batch file wrapper:<div><br></div><div><font \
class="Apple-style-span" face="'Courier New'"><br></font><div><div><font \
class="Apple-style-span" face="'Courier New'">@echo off</font></div><div><font \
class="Apple-style-span" face="'Courier New'">set \
perl_bindir=C:\Perl\bin</font></div><div><font class="Apple-style-span" \
face="'Courier New'">set PATH=%PATH%;"C:\Program Files \
(x86)\GNU\GnuPG\pub"</font></div><div><font class="Apple-style-span" face="'Courier \
New'"><br></font></div><div><font class="Apple-style-span" face="'Courier \
New'">%perl_bindir%\perl.exe -x -S %0</font></div><div><font class="Apple-style-span" \
face="'Courier New'"><br></font></div><div><font class="Apple-style-span" \
face="'Courier New'">goto endofperl</font></div><div><font class="Apple-style-span" \
face="'Courier New'"><br></font></div><div><font class="Apple-style-span" \
face="'Courier New'">#!perl</font></div></div><div><div><font \
class="Apple-style-span" face="'Courier New'">BEGIN {</font></div><div><font \
class="Apple-style-span" face="'Courier New'"><span class="Apple-tab-span" \
style="white-space:pre">	</span>use Win32 qw( SW_HIDE );</font></div><div><font \
class="Apple-style-span" face="'Courier New'"><span class="Apple-tab-span" \
style="white-space:pre">	</span>Win32::SetChildShowWindow( SW_HIDE \
);</font></div><div><font class="Apple-style-span" face="'Courier \
New'">}</font></div><div><font class="Apple-style-span" face="'Courier \
New'"><br></font></div><div><font class="Apple-style-span" face="'Courier New'">use \
strict;</font></div><div><font class="Apple-style-span" face="'Courier New'">use \
warnings;</font></div><div><font class="Apple-style-span" face="'Courier \
New'"><br></font></div><div><font class="Apple-style-span" face="'Courier New'">my \
$log = "decrypt.log";</font></div><div><font class="Apple-style-span" face="'Courier \
New'"><br></font></div><div><font class="Apple-style-span" face="'Courier New'">close \
( STDOUT );</font></div><div><font class="Apple-style-span" face="'Courier New'">open \
( STDOUT, "&gt;&gt;$log" );</font></div><div><font class="Apple-style-span" \
face="'Courier New'"><br></font></div><div><font class="Apple-style-span" \
face="'Courier New'">close (STDERR );</font></div><div><font class="Apple-style-span" \
face="'Courier New'">open (STDERR, "&gt;&gt;$log" );</font></div><div><font \
class="Apple-style-span" face="'Courier New'"><br></font></div><div><font \
class="Apple-style-span" face="'Courier New'"># The below are commented out as I am \
entering them directly on the command line for troubleshooting \
purposes.</font></div><div><font class="Apple-style-span" face="'Courier \
New'"><br></font></div><div><font class="Apple-style-span" face="'Courier New'"># my \
$data_file = "TEST_FILE.txt.pgp";</font></div><div><font class="Apple-style-span" \
face="'Courier New'"># my $incoming_dir = "C:<a \
href="smb://Users//Public//TEST//Incoming">\\Users\\Public\\TEST\\Incoming</a>";</font></div><div><font \
class="Apple-style-span" face="'Courier New'"># my $data = "C:<a \
href="smb://Users//Public//TEST//Incoming//TEST_FILE.txt.pgp">\\Users\\Public\\TEST\\Incoming\\TEST_FILE.txt.pgp</a>";</font></div><div><font \
class="Apple-style-span" face="'Courier New'"># my $output_file = \
$data_file;</font></div><div><font class="Apple-style-span" face="'Courier New'"># \
$output_file =~ s/\.pgp//;</font></div><div><font class="Apple-style-span" \
face="'Courier New'"><br></font></div><div><font class="Apple-style-span" \
face="'Courier New'"># my $data_dir = "C:<a \
href="smb://Users//Public//TEST//Data">\\Users\\Public\\TEST\\Data</a>";</font></div><div><font \
class="Apple-style-span" face="'Courier New'"># my $output = "C:<a \
href="smb://Users//Public//TEST//Data//TEST_FILE.txt">\\Users\\Public\\TEST\\Data\\TEST_FILE.txt</a>";</font></div><div><font \
class="Apple-style-span" face="'Courier New'"><br></font></div><div><font \
class="Apple-style-span" face="'Courier New'"># my $sec_keyring = "C:<a \
href="smb://Users//Administrator//AppData//Roaming//gnupg//secring.gpg">\\Users\\Administrator\\AppData\\Roaming\\gnupg\\secring.gpg</a>";</font></div><div><font \
class="Apple-style-span" face="'Courier New'"># my $pub_keyring = "C:<a \
href="smb://Users//Administrator//AppData//Roaming//gnupg//pubring.gpg">\\Users\\Administrator\\AppData\\Roaming\\gnupg\\pubring.gpg</a>";</font></div><div><font \
class="Apple-style-span" face="'Courier New'"><br></font></div><div><font \
class="Apple-style-span" face="'Courier New'">system ( "gpg2.exe --batch --yes \
--passphrase-fd 0 --output C:<a \
href="smb://Users//Public//TEST//Data//TEST_FILE.txt">\\Users\\Public\\TEST\\Data\\TEST_FILE.txt</a> \
--no-default-keyring --keyring C:<a \
href="smb://Users//Administrator//AppData//Roaming//gnupg//pubring.gpg">\\Users\\Administrator\\AppData\\Roaming\\gnupg\\pubring.gpg</a> \
--secret-keyring &nbsp;C:<a \
href="smb://Users//Administrator//AppData//Roaming//gnupg//secring.gpg">\\Users\\Administrator\\AppData\\Roaming\\gnupg\\secring.gpg</a> \
--exit-on-status-write-error --decrypt C:<a \
href="smb://Users//Public//TEST//Incoming//TEST_FILE.txt.pgp">\\Users\\Public\\TEST\\Incoming\\TEST_FILE.txt.pgp</a> \
&lt; passphrase.txt" );</font></div><div><font class="Apple-style-span" \
face="'Courier New'"><br></font></div><div><div apple-content-edited="true"> \
<div><div><font class="Apple-style-span" face="'Courier \
New'"><br></font></div><div><font class="Apple-style-span" face="'Courier \
New'">__END__</font></div><div><font class="Apple-style-span" face="'Courier \
New'">:endofperl</font></div><div style="font-size: 14px; "><br></div></div><div \
style="font-size: 14px; ">Works fine. My regrets for the distraction...</div><div \
style="font-size: 14px; "><br></div><div style="font-size: 14px; ">Scott...</div><div \
style="font-size: 14px; "><br></div><div style="font-size: 14px; "><br></div><br \
class="Apple-interchange-newline"> </div>
<br></div></div>_______________________________________________<br>Gpg4win-users-en \
mailing list<br><a href="mailto:Gpg4win-users-en@wald.intevation.org">Gpg4win-users-en \
@wald.intevation.org</a><br>http://lists.wald.intevation.org/cgi-bin/mailman/listinfo/gpg4win-users-en</div></body></html>




_______________________________________________
Gpg4win-users-en mailing list
Gpg4win-users-en@wald.intevation.org
http://lists.wald.intevation.org/cgi-bin/mailman/listinfo/gpg4win-users-en

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic