Re: how to pass variables to script when using php from command line
| From: | John Donagher | Date: | Mon, 30 Oct 2000 15:28:58 +0000 |
| Subject: | Re: how to pass variables to script when using php from command line | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-22735@lists.php.net to get a copy of this message | ||
On Mon, 30 Oct 2000, Oguz wrote:
> I need to write a web page that can mail to thousands of our users same kind
> of mail. I didn't think that doing this from apache module php was a good
> idea. So I compiled php to another directory as cgi. I can use it from
> command line now. So I will get a message from the web page to a regular
> .php page, which will then do st. like
> exec("php massmailscript.php"); and return. The cgi type php script will be
> still running though.
>
> Problem is: I don't know how to pass variables to the script.
>
>
> I suppose I should be able to do
> php massmailscript.php message="..........."
> But how to use arguments in massmailscript? Is there something like
> argc-argv?
>
> Also, the $message can be pretty long and can include newlines. So doing st
> like
> exec("php massmailscript.php message=$message", $results);
> may not be a good idea.
>
Oguz-
$argc and $argv are available in the script's namespace by turning on register_argc_argv in
php.ini. Otherwise, they are available through $GLOBALS.
PHP does have the capability to read from stdin. You may want to consider calling the script like:
./myscript.php < /tmp/themessage
That should get you around any problems with passing in terminating characters on the command line.
If you will be mailing thousands of users from a single thread, make sure you play around with the
script timeout either in php.ini or by calling the set_time_limit() function from your script.
--
John Donagher
Application Engineer
Intacct Corp. - Powerful Accounting on the Web
408-395-0989
720 University Ave.
Los Gatos CA 95032
www.intacct.com
-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: GnuPG v1.0.1 (GNU/Linux)
Comment: For info see http://www.gnupg.org
mQGiBDnCZ1oRBACFgkFCV6p3dWic1qm1FLhip5beIyzZSt+ccTDYQQdPZA/t5H+k
PZ7ZFBIUrXz/oEqwQwlEKlg8JQqg7hgtcL+xrIJ0BInLeSJG4lvvB551g59Thr7/
OsdxNVxKci775+K+GkdAz4xcULMuB+QE7t665Ri46EAS8ALos5UG6DGmhwCguD0v
1cxwy/KlKr+oi4sWM9caueED/RmjiSD3vmBZQt6PMisVe1AmkEf6cJoemduCSJxu
0eMz/LIeu+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