The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
how to know if the mailx command really sends the mail to the email address? sheenshine Shell Programming and Scripting 3 09-17-2008 09:34 AM
write the script to get the file size and sends an email s_linux Shell Programming and Scripting 10 08-14-2008 12:54 AM
running sql script and email it adzuanamir UNIX for Dummies Questions & Answers 3 07-07-2008 05:13 AM
Shell script not running thru Cronjob gauravshrinivas Shell Programming and Scripting 8 11-03-2006 10:17 AM
Variables are not getting exported while running the script in cronjob csaha Shell Programming and Scripting 7 03-21-2006 04:32 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 09-16-2008
Nightowl Nightowl is offline
Registered User
  
 

Join Date: Sep 2008
Posts: 8
Running script that sends an html formatted email fails when its run as cronjob

Hi

Im very new at working with unix and this problem I simply can not understand. I know there are a lot of threads about problems with shell scripts behaving differently when run from a terminal and from a cronjob. I have tried everything(almost) but I still havent cracked this problem.

Im working with typo3 and an extension called aux_newsmailer. The extension, when working properly, is suppose to send out newsletter automatically to users. Either formatted as plain text or html. My problem is that the extension has a backend userface where you manually can send the newsletters which works. Also, running the mailer script from a terminal works fine. When I, however, tries to run the script from a cronjob the html mails are somehow not received by all users and those mails that does are not formatted correctly, images are missing and links are not formatted the right way.

I have concluded that the error has something to do with the sending/formatting process but thats all I know.

Has anyone any idea what might be the problem?

/Nightowl
  #2 (permalink)  
Old 09-16-2008
cfajohnson's Avatar
cfajohnson cfajohnson is offline Forum Advisor  
Shell programmer, author
  
 

Join Date: Mar 2007
Location: Toronto, Canada
Posts: 2,380
The usual problem when a cron job script doesn't work, but the script works from the command line is that the environment is different. Usually, the PATH must be defined in the script.

If the problem is not the PATH, check other variables that the script depends on.
  #3 (permalink)  
Old 09-16-2008
Nightowl Nightowl is offline
Registered User
  
 

Join Date: Sep 2008
Posts: 8
Ok, I have been around this before and the environment is quite different, though, Im not sure which variables the script depends on or how to change the variables like PATH. How is this done?

I have tried to type:
PATH=/root/bin etc, but this returns an error

Can you help?
  #4 (permalink)  
Old 09-16-2008
cfajohnson's Avatar
cfajohnson cfajohnson is offline Forum Advisor  
Shell programmer, author
  
 

Join Date: Mar 2007
Location: Toronto, Canada
Posts: 2,380
Quote:
Originally Posted by Nightowl View Post
Ok, I have been around this before and the environment is quite different, though, Im not sure which variables the script depends on or how to change the variables like PATH. How is this done?

Read the script and see what variables it uses but does not set.
Quote:
I have tried to type:
PATH=/root/bin etc,

Where did you type it?

What, exactly, did you type?
Quote:
but this returns an error

What is the error?
  #5 (permalink)  
Old 09-16-2008
sudhamacs sudhamacs is offline
Registered User
  
 

Join Date: Jun 2008
Posts: 98
What is the error that u r getting?

PS:U can place 2>error.log in ur cron script to get the error messages logged to a file.
  #6 (permalink)  
Old 09-16-2008
Nightowl Nightowl is offline
Registered User
  
 

Join Date: Sep 2008
Posts: 8
I dont think any of the variables are actually used or I just dont get it

Here is the shell script written in php:

#! /usr/bin/php -q
<?php


// set typo path to point to the root of the T3 installation
$typopath='/var/www/typo3/mysite/';

// create a BE user called _cli_auxnewsmailer (must not be admin), for better security change it to somethine else.
$MCONF['name'] = '_CLI_auxnewsmailer';

// *****************************************

// Standard initialization of a CLI module:

// *****************************************


if (@is_file($typopath.'typo3conf/ext/aux_newsmailer/mod1/index.php'))
$modulepath=$typopath.'typo3conf/ext/aux_newsmailer/';
else
$modulepath=$typopath.'typo3/ext/aux_newsmailer/';

// Defining circumstances for CLI mode:

define('TYPO3_cliMode', TRUE);

//$BACK_PATH = '../../../../typo3/';
define('TYPO3_mainDir', 'typo3/');
define('PATH_thisScript',$typopath.'typo3/typo3');
define('TYPO3_MOD_PATH', $modulepath.'/mailer/');
// Include init file:
require($typopath.'typo3/init.php');
require($typopath.'typo3/sysext/lang/lang.php');

$LANG=t3lib_div::makeInstance('language');
$LANG->init('default');


require($modulepath.'mod1/class_auxnewsmailer_core.php');


$mailer=new tx_auxnewsmailer_core;
$mailer->init();

$mailer->batch($argv[1],'','');



?>

I typed in the PATH=/root/bin in the top of this document and the error returned was
PHP Warning: Cannot modify header information - headers already sent by (output started at /var/www/typo3/mydomain/typo3conf/ext/aux_newsmailer/mailer/mailer.sh:3) in /var/www/typo3/mydomain/typo3_src-4.2.1/t3lib/class.t3lib_userauth.php on line 278
  #7 (permalink)  
Old 09-16-2008
cfajohnson's Avatar
cfajohnson cfajohnson is offline Forum Advisor  
Shell programmer, author
  
 

Join Date: Mar 2007
Location: Toronto, Canada
Posts: 2,380
Quote:
Originally Posted by Nightowl View Post
I dont think any of the variables are actually used or I just dont get it

Here is the shell script written in php:

#! /usr/bin/php -q
<?php
...
?>
I typed in the PATH=/root/bin in the top of this document and the error returned was
PHP Warning: Cannot modify header information - headers already sent by (output started at /var/www/typo3/mydomain/typo3conf/ext/aux_newsmailer/mailer/mailer.sh:3) in /var/www/typo3/mydomain/typo3_src-4.2.1/t3lib/class.t3lib_userauth.php on line 278

That's a PHP script, not a shell script.

You cannot use shell syntax in PHP.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 09:06 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0