I've got a script, which I've copied below, that does an encryption of a file with 0.09 GnuPG Perl module, 1.06 GnuPG, egd-0.8, HP-UX 11.0, Perl 5.6.1.

What I'm seeing in the logs is that when the script reaches the file encryption line (not instantiation), it stops (issuing NO errors), and restarts from the top of the Perl script all by itself! The second time it arrives at the file encryption line, it works fine and moves on. I know its doing this repeating by use of a log, and it only happens when I redirect the output and error stuff to files. When run from the command line and letting it spit out to the screen, it runs absolutely as I'd expect (no restarting observed).

Anyone see anything like this before? Thoughts on where/how to troubleshoot what the cause could be? I know it doesn't occur w/ other Perl scripts, just the one that uses GnuPG and its associated module, but how can I tell if this's from the GnuPG module or the application (or something else entirely)?

#! /usr/local/perl/bin/perl -w #use strict; use GnuPG ; use Net::SMTP; use DBI; $gsDSN="dev"; $gsPassPhrase="passphrase"; $gsLogPath = "/home/autopca/ecomoper"; $gsRecipient = "RECIPIENT"; my (@gsaFields,$gsPLine,$gsALine,$gsHeader,$gsWriteLog,$gsOnlyAcctID,$ +gsAccount_EFile2); my ($gsPayment_File, $gsAccount_File, $gsAccount_Encrypted, $gsWhich_F +ile,$gDBI); my $gsPath = "$gsLogPath/ecom/scripts/"; $gsLogPath .= "/ecom/tmp/"; #*******Call subs********** print "Beginning send.pl.\n"; print "******************************"; print "Beginning Payment processing.\n"; &ReadPaymentFile; #********************************************************************* +************************** # ReadPaymentFile #********************************************************************* +************************** #This sub reads the payment file written by Oracle and call GPG functi +on sub ReadPaymentFile { my (@saLine,$iCount,$iPos,$sVlu,$iPos2,$saLine); #open the proper file $gsPayment_File = $gsPath . "clear.txt"; $gsPLine= ""; if (!(open (INI, "$gsPayment_File"))) { print "Payment file error: $gsPayment_File not open:$!\n"; exit(1); } #Assign the file's contents to saLine @saLine = <INI>; close (INI); $iCount=0; #Loop through the lines of the file parsing out what we want foreach $saLine (@saLine) { chomp $saLine; if (!(length($saLine) == 80)){ print "not 80 byte:". $saLine; } $gsPLine .= $saLine."\n"; } $gsWriteLog = "Start with Payment : Sent to PGpg. "; print "Payment file read.\n"; PGpg($gsPayment_File); } #********************************************************************* +********************** # PGpg #********************************************************************* +********************** #This sub sign and encrypt payment file and call ftp function sub PGpg { my ($sFile_Name) = @_; my ($gpg); if ($gsDSN ne "dev") { #Production/QA gpg setup $gpg = new GnuPG (Homedir => "~/.gnupg", trace => $ENV{TRACING +}, gnupg_path=>"/usr/local/gnupg/bin/gpg" ); } else { #Development gpg setup $gpg = new GnuPG (Homedir => "~/.gnupg", trace => $ENV{TRACING +}, gnupg_path=>"/usr/bin/gpg" ); } if ($sFile_Name =~ /clear.txt/) { $gsWhich_File = $gsPath ."cipher.txt"; print "Encrypting payment file $sFile_Name with key $gsRecipie +nt.\n"; eval {$gpg -> encrypt ( recipient => $gsRecipient, output => $gsWhich_File, armor => 1, plaintext => $sFile_Name, sign => 1, "local-user" => FF743118, passphrase => $gsPassPhrase, ); }; if ($@) { print "Errors from gpg encryption of payment file:$@\n +"; exit(1); } print "Payment PGP Done. Start Transferring payment input file + ($gsWhich_File).\n"; } } 1;

In reply to GnuPG and auto script restart by kanwisch

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.