Posted by Janwillem Borleffs on 12/23/05 17:32
Dave Kelly wrote:
> I'm new to php and haven't got a clue what I'm doing.
> I need to pass a variable from a bash script to a phpmailer function.
>
[...]
> Here is the error message I get when the program aborts.
>
> daveekelly@earthlink.net is admin
> --just before the php code
> Message was not sentMailer Error: Language string failed to load:
> recipients_failed
>
>
> Here is the code that calls the php code.
>
Here's a bash script showing the basics:
#!/usr/bin/bash
function mailsender {
recepient=$1
php -r "echo '$recepient';"
}
admin_mail=$1
mailsender $admin_mail
Note the use of double/single quotes within the mailsender function.
Also note that you do not need to use bash for this, but also pure php:
test.php:
<?php
if (isset($_SERVER['argv'][1])) {
echo "Hello {$_SERVER['argv'][1]}";
} else {
echo "Hello Unknown";
}
?>
Call: $ php -f test.php John
For more info, see: http://www.php.net/features.commandline
JW
Navigation:
[Reply to this message]
|