Auto Processing and Perl Scripts

All:

I have a Perl script that is initiated through an auto processing queue. The script works perfectly in generating the final PDF; but, cannot seem to run the mailx command in order to send the PDF back to the user.

The following is the code for executing the mailx command:

print "e-Mailing $PDF_FILE file to people on mailing list.\n\n";

$message = "PDF for $PUB_NAME attached.\n\n";

open(MAIL, "| /bin/mailx -s $PUB_NAME -a $PDF_FILE Herold.Moitoso\@lc.ca.gov" ) or die "mailx failed: $!\n\n";

# Email Body
print MAIL $message;

close(MAIL);

There are no error messages generated any where; the auto process queue reports successful completion, with no errors. And my logging file also does not report any errors.

If I manually run the script from the command line, everything works correctly including receiving the complete E-mail message with the completed PDF as an attachment.

I was wonder if anyone has encountered similar type of behavior between auto processing and manually running a script, and if anyone has found a solution.

Any advise would be greatly appreciated.

Herold M. Moitoso

Enterprise Applications & Reporting Section

Legislative Data Center

  • Herold,

    Did you check the queue entries with conshell to see if the "user" running the task (BY: xxxx) was the same as your account, or is it a different user?

    The user to run the task (on Unix) is determined by the owner of the file created in the auto-processing directory, or the user doing the 'enque' command if a background task is being entered directly with the 'enque' command.

    Perhaps that particular user, if it is different, is not set up correctly on the system running the bgquer service (and thus the queued tasks) to send mail?

    Just a shot-in-the-dark.

    Jonathan Dagresta
    RWS Group/
    XPP Development

  • I'm the "user" testing this process, I'm also the owner of the file being dropped into the auto-processing directory.

    The Conshell reports no errors with Status: completed.

    That's what's been driving me crazy... I can't find anything anywhere indicating any type of error.

    I've even purposefully entered a syntax error, to see it would trap an obvious error, and Conshell did report the error.

    The issue seems to be related to the "-a" switch for the attachment, if I remove the the "-a attached_file" argument, it runs fine sending me an email with a Subject, and Body; just no attachment which is the most important part.

    And it is very odd that if I run the Perl script from the command line, using the very same file I've been dropping into the auto-processing folder, it works perfectly fine.

    I receive and e-mail, with the correct Subject, Body, and the attached PDF file.

    And, thanks for responding so soon.
  • Only asking this because of not being able to see the "details", but is the value of $PDF_FILE being used for the -a switch a full path?

    Jonathan Dagresta
    RWS Group/
    XPP Development

  • Yes, $PDF_FILE is the full path.

    When I run it from the command line, I enter the full path, i.e., /df/xyvision/jobs/pubxppidev1/AJI/alljobz/CLS_aji-proc/GRP_aji/JOB_aji/DIV_output/aji_2011-12-rs.pdf

    That's what the $PDF_FILE variable contains.

    It prints out the expansion correctly in my log file, snippet below:

    Finished Generating aji_2011-12-rs.pdf file.

    Finished Generating aji_2011-12-rs.ps file.

    Current working directory is: /df/xyvision/jobs/pubxppidev1/AJI/alljobz/CLS_aji-proc/GRP_aji/JOB_aji/DIV_output

    PDF File is: /df/xyvision/jobs/pubxppidev1/AJI/alljobz/CLS_aji-proc/GRP_aji/JOB_aji/DIV_output/aji_2011-12-rs.pdf

    e-Mailing /df/xyvision/jobs/pubxppidev1/AJI/alljobz/CLS_aji-proc/GRP_aji/JOB_aji/DIV_output/aji_2011-12-rs.pdf file to people on mailing list.

    Is there a possibility that this particular variable with the -a switch, is not being expanded?

    Again, thanks for the response.
  • If the $PDF_FILE variable with the -a switch was not being expanded, then I would expect you to get the same failure when you test from the command line.

    So you have verified that $PDF_FILE is the full path when you run your test from the command line, but have you verified that this is the case when running via auto-processing (i.e. in a background queue)?

    Sorry, I'm really just "grasping at straws" because I'm out of ideas. :)

    Jonathan Dagresta
    RWS Group/
    XPP Development

  • I see the $PDF_FILE expanded in the log files I write, but I don't know where to look in the background queues to see a fully expanded command run through auto-proc queue.
    I've looked at the messages in the Conshell but it doesn't show any of the commands, and less they have and error and fail.
    Is there some place I can look to see the fully expanded commands that auto-proc ran?
    Thanks
  • If you're seeing the $PDF_FILE expanded in your log files, then that would seem to indicate that it's the full path when running in the background queue via auto-processing.

    In Conshell, you click on a Log entry for the specific queue to expand the entry and show the full command that was entered by auto-processing and run by the bgquer service. But you'll only see the (full) command that it ran and the last message (Progress: xxx) that was written out to standard output by the command, unless error messages were written to standard error (which are all displayed).

    Jonathan Dagresta
    RWS Group/
    XPP Development

  • This is what I see in the Conshell.

    Nothing showing the mailx command string.

  • Yes, as I said the "Progress:" line of a Log entry in Conshell shows only the last message that is written by the process to standard output.

    If you want your mailx command string to show on the "Progress:" line of the Log entry then the last thing your command should write (or echo) to standard output would be the mailx command string.

    Either that or write (echo) you mailx command to standard error (at any point) and it will always be shown in the Log entry (when you click on it) as an error message; however I think that will make the bgquer service think that the task "failed" (if anything is written out by the task to standard error). But you could just temporarily do that just to see what you get.

    Jonathan Dagresta
    RWS Group/
    XPP Development

  • Herold,

    It might be a lot easier to print all your debug information into a separate log file that you create yourself from your program.

    Bart