[Templates] problems with %ENV when using TT from cron?
Michael South
msouth at mcclatchyinteractive.com
Tue Jan 29 21:11:29 GMT 2008
On Jan 29, 2008 3:31 PM, David Martin <designs at nolaflash.com> wrote:
> Hello,
>
>
>
> I have an inherited script that sends an email using TT to assemble an
> email. The template syntax compiles fine, and the script actually succeeds
> without issue from the commandline. However when cron runs the script the
> $response variable is empty.
>
>
>
> I have verified that the only variable that is altered in cron vs cmd line
> is %ENV so I making an educated guess that this is somehow causing $response
> to be empty.
>
>
>
> my $response = '';
>
> $tt->process( 'process_response.tt2', {
>
> data => $data,
>
> env => \%ENV,
>
> context => 'email'
>
> }, \$response );
>
> First things first--you need to add error checking. TT may be trying to
help you, but you aren't getting the benefit because your script ignores the
return value of the process() call. Add "|| die $tt->error" before that
final semicolon and see what you get from cron. (Also make sure, like Andrew
said, that you are getting error messages that your cron scripts emit. Test
that by cronning a script that die()s first, I guess.)
mike
>
>
> I have captured the contents of %ENV from both environments and pasted
> below my sig. Anyone see what may be causing issues? Any advice as to how
> to fix?
>
>
>
> Is this too little information?
>
>
>
> David Martin
> NolaFlash.com <http://www.nolaflash.com/>
> Web Design, Programming and Hosting
>
> 4600 S Tonti St
> NO LA 70125
> 504.583.3755
>
> <http://www.nolaflash.com/>
>
>
>
> ## CMD LINE %ENV ##
>
> $VAR1 = 'HOME';
>
> $VAR2 = '/home/david';
>
> $VAR3 = 'SSH_CLIENT';
>
> $VAR4 = 'ip stuff here';
>
> $VAR5 = 'SSH_CONNECTION';
>
> $VAR6 = 'more ip stuff';
>
> $VAR7 = 'BLOCKSIZE';
>
> $VAR8 = 'K';
>
> $VAR9 = 'EDITOR';
>
> $VAR10 = 'pico';
>
> $VAR11 = 'MAIL';
>
> $VAR12 = '/var/mail/david';
>
> $VAR13 = 'PWD';
>
> $VAR14 = '/home/david';
>
> $VAR15 = 'USER';
>
> $VAR16 = 'david';
>
> $VAR17 = 'LOGNAME';
>
> $VAR18 = 'david';
>
> $VAR19 = 'SHLVL';
>
> $VAR20 = '1';
>
> $VAR21 = '_';
>
> $VAR22 = '/usr/bin/perl';
>
> $VAR23 = 'ENV';
>
> $VAR24 = '/home/david/.shrc';
>
> $VAR25 = 'PATH';
>
> $VAR26 =
> '/sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/usr/local/sbin:/usr/local/bin:/usr/X11R6/bin:/home/david/bin';
>
> $VAR27 = 'FTP_PASSIVE_MODE';
>
> $VAR28 = 'YES';
>
> $VAR29 = 'SHELL';
>
> $VAR30 = '/usr/local/bin/bash';
>
> $VAR31 = 'TERM';
>
> $VAR32 = 'vt100';
>
> $VAR33 = 'PAGER';
>
> $VAR34 = 'more';
>
> $VAR35 = 'SSH_TTY';
>
> $VAR36 = '/dev/ttyp3';
>
>
>
> ## CRON %ENV ##
>
> $VAR1 = 'HOME';
>
> $VAR2 = '/home/david';
>
> $VAR3 = 'LOGNAME';
>
> $VAR4 = 'david';
>
> $VAR5 = 'SHELL';
>
> $VAR6 = '/bin/sh';
>
> $VAR7 = 'USER';
>
> $VAR8 = 'david';
>
> $VAR9 = 'PATH';
>
> $VAR10 = '/usr/bin:/bin';
>
>
>
> _______________________________________________
> templates mailing list
> templates at template-toolkit.org
> http://mail.template-toolkit.org/mailman/listinfo/templates
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.template-toolkit.org/pipermail/templates/attachments/20080129/861b4a78/attachment.htm
More information about the templates
mailing list