On 25-Sep-2002 Daren Cotter wrote:
> Jason,
> 
> That's exactly what I'm trying to do, and it's not
> working:
> 
> My Script: 
>#!/usr/bin/php -f
> <?php
> $test = $argv[1];
> print $test;
> $demo = "This Works";
> print $demo;
> ?>
> 
> Running:
> ./test.php blah
> 
> Yiels only "This Works", but not "blah".
> 
> I'm using version 4.0.6
> 

try 

var_dump($argv);
var_dump($GLOBALS);
> 
> --- Jason Young <[EMAIL PROTECTED]> wrote:
>> I can't say I'm really too familiar with the php
>> commandline..
>> 
>> You're using /usr/bin/php (or equivalent) and
>> attempting to use your 
>> exec() that way?
>> 
>> If you do 'php -?' you'll get a list of commands
>> that you can use, and I 
>> don't see a way to pass cmdline arguments as
>> variables..
>> 
>> Having said that, I Just went and looked further
>> into it.. if I make a 
>> test script, and at the top I put:
>> $hi = $argv[1];
>> 
>> then $hi becomes whatever you've specified as the
>> first argument.. I'm 
>> assuming this is what you want?
>> 
>> To clarify:
>> phpfile.php contains:
>> <?
>> $hi = $argv[1];
>> echo $hi;
>> ?>
>> 
>> Running the command "php -f phpfile.php test"
>> returns "test"
>> 
>> Does this help at all??
>> 
>> -Jason
>> 
>> Daren Cotter wrote:
>> > Jason,
>> > 
>> > I'm not using a web script any longer, I'm using
>> > command-line (I determined that it is installed on
>> the
>> > server).
>> > 
>> > I read about $argc and $argv, but when I call the
>> > script passing two arguments, both $argc and $argv
>> are
>> > blank. Is this a php.ini setting I need to change
>> or
>> > somethign?
>> > 
>> > --- Jason Young <[EMAIL PROTECTED]> wrote:
>> > 
>> >>Sorry to butt in :)
>> >>
>> >>Arguments to web scripts are done in the format:
>> >>page.php?arg1=data1&arg2=data2
>> >>
>> >>So you would use that full string as the lynx
>> path.
>> >>
>> >>Hope this helps :)
>> >>-Jason
>> >>
>> >>Daren Cotter wrote:
>> >>
>> >>>Thanks for the info Chris, it works!
>> >>>
>> >>>How do I pass arguments to the script? I'm
>> >>
>> >>assuming
>> >>
>> >>>it'd just be:
>> >>>
>> >>>test.php arg1 arg2
>> >>>
>> >>>The stuff I've read says $argc should be the
>> count
>> >>
>> >>of
>> >>
>> >>>the # of arguments, and $argv should be an array
>> >>>holding them...but when I do a simple:
>> >>>print "# of Arguments: $argc\n";
>> >>>It prints nothing, not even 0
>> >>>
>> >>>
>> >>>--- Chris Hewitt <[EMAIL PROTECTED]>
>> >>
>> >>wrote:
>> >>
>> >>>>>On Wed, 25 Sep 2002, Daren Cotter wrote:
>> >>>>>
>> >>>>>
>> >>>>>
>> >>>>>>My problem, is that I absolutely NEED to run a
>> >>>>>
>> >>PHP
>> >>
>> >>>>>>script using crontab. The script needs to send
>> >>>>>>numerous queries to a database every hour. Is
>> >>>>>
>> >>>>there
>> >>>>
>> >>>>
>> >>>>>>any way I can accomplish this, directly or
>> >>>>>
>> >>>>indirectly?
>> >>>>
>> >>>>Are you sure its not already there? Commonly in
>> >>>>/usr/bin. Try a "which 
>> >>>>php" and see if it finds anything?
>> >>>>
>> >>>>HTH
>> >>>>Chris
>> >>>>
>> >>>
>> >>>
>> >>>
>>
>>>>__________________________________________________
>> >>>Do you Yahoo!?
>> >>>New DSL Internet Access from SBC & Yahoo!
>> >>>http://sbc.yahoo.com
>> >>
>> >>
>> >>-- 
>> >>PHP General Mailing List (http://www.php.net/)
>> >>To unsubscribe, visit:
>> http://www.php.net/unsub.php
>> >>
>> > 
>> > 
>> > 
>> > __________________________________________________
>> > Do you Yahoo!?
>> > New DSL Internet Access from SBC & Yahoo!
>> > http://sbc.yahoo.com
>> 
>> 
>> -- 
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>> 
> 
> 
> __________________________________________________
> Do you Yahoo!?
> New DSL Internet Access from SBC & Yahoo!
> http://sbc.yahoo.com
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php

-- 
Don Read                                       [EMAIL PROTECTED]
-- "Beer is proof that God loves us and wants us to be happy."

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to