The installed php on CentOS/RHEL is the CGI version. This means I should be able to get command line arguments with $GLOBALS[''argv''] or $_SERVER[''argv'']. That''s how the php documentation tells and how it works f.i. on Suse. However, on CentOS I get them only when I use the -n switch to php (no php.ini). The problem with -n is that php cannot find the mysql_connect function for some unknown reason. So, how can I get to argv without using -n? Or can I add the cli version with an additional rpm? I search with yum for php-cli and cli-php, but didn''t find such a package. Kai -- Kai Sch?tzl, Berlin, Germany Get your web at Conactive Internet Services: http://www.conactive.com
On 3/30/06, Kai Schaetzl <maillists@conactive.com> wrote:> The installed php on CentOS/RHEL is the CGI version. This means I should > be able to get command line arguments with $GLOBALS[''argv''] or > $_SERVER[''argv'']. That''s how the php documentation tells and how it works > f.i. on Suse. > However, on CentOS I get them only when I use the -n switch to php (no > php.ini). The problem with -n is that php cannot find the mysql_connect > function for some unknown reason. > > So, how can I get to argv without using -n? > Or can I add the cli version with an additional rpm? I search with yum for > php-cli and cli-php, but didn''t find such a package.The mysql functionality is loaded as a module which is included from php.ini. If you don''t load php.ini, you get no mysql. -- "They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety'''' Benjamin Franklin 1775
On Fri, 2006-03-31 at 02:29 +0200, Kai Schaetzl wrote:> The installed php on CentOS/RHEL is the CGI version. This means I should > be able to get command line arguments with $GLOBALS[''argv''] or > $_SERVER[''argv'']. That''s how the php documentation tells and how it works > f.i. on Suse. > However, on CentOS I get them only when I use the -n switch to php (no > php.ini). The problem with -n is that php cannot find the mysql_connect > function for some unknown reason. > > So, how can I get to argv without using -n? > Or can I add the cli version with an additional rpm? I search with yum for > php-cli and cli-php, but didn''t find such a package.http://www.php.net/manual/en/ini.core.php#ini.register-argc-argv -- Ignacio Vazquez-Abrams <ivazquez@ivazquez.net> http://centos.ivazquez.net/ gpg --keyserver hkp://subkeys.pgp.net --recv-key 38028b72 -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 191 bytes Desc: This is a digitally signed message part Url : http://lists.centos.org/pipermail/centos/attachments/20060330/775b5dbb/attachment.bin
Jim Perrin wrote on Thu, 30 Mar 2006 19:59:03 -0500:> The mysql functionality is loaded as a module which is included from > php.ini. If you don''t load php.ini, you get no mysql.Ah, makes sense, thanks. Do you know why I need the -n switch to get at these arguments on CentOS? Kai -- Kai Sch?tzl, Berlin, Germany Get your web at Conactive Internet Services: http://www.conactive.com
Ignacio Vazquez-Abrams wrote on Thu, 30 Mar 2006 20:31:05 -0500:> http://www.php.net/manual/en/ini.core.php#ini.register-argc-argvIgnacio, I do not want to access $argv[]. I want to access argv according to the documented way, however, this works on CentOS only if I use the -n switch. This is not like it is on other distributions and it is different than the php documentation says. Yes, I''m fully aware that this is very surely a problem in RHEL and CentOS just inherits it. I don''t blame anyone for this, I just ask for information. This "tiny" change means that you have to use a different config file for command line usage of php because it''s pretty useless without command line arguments or mysql. Kai -- Kai Sch?tzl, Berlin, Germany Get your web at Conactive Internet Services: http://www.conactive.com
On Fri, 31 Mar 2006, Kai Schaetzl wrote:> The installed php on CentOS/RHEL is the CGI version. This means I should > be able to get command line arguments with $GLOBALS['argv'] or > $_SERVER['argv']. That's how the php documentation tells and how it works > f.i. on Suse.with an utterly stock Centos, this code fragment 'just works', including database access: [herrold at centos-4 gnuplot]$ grep -v ^$ plots.php | grep -v ^#$ \ | head -20 #!/usr/bin/php -qc/etc <?php $screen = 1 ; $screen = 0 ; $ARGC = $_SERVER["argc"]; $ARGV = array(); $ARGV = $_SERVER["argv"]; // include("/home/herrold/shim/database_trender_keying.php"); include("/home/herrold/shim/database_trender_open.php"); include("/home/herrold/shim/database_beancounter_keying.php"); include("/home/herrold/shim/database_beancounter_open.php"); // $demog_value = array(); // $nonce = $ARGC ; $counter = 0 ; // print "$ARGC: \n"; while ( $nonce > 1 ) { $nonce -= 1 ; $counter += 1 ; ... -- Russ Herrold