PHP Installation
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsPHP RelatedPHP Installation

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
  #1  
Old August 12th, 2002, 02:27 PM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 25
commandline + Linux

I can not get working php correctly from the command line under Linux.
php install(php version 4.2.1):
1.configure --enable-cli
2.make
3.make install

I tested with the following script(cline.php):

#!/usr/local/bin/php // my php file is under /usr/local/bin
<?php

if ($argc == 2) echo "1 argument";
else echo "no arguments";

?>

Now my problem is that it always outputs : "no arguments"
even if run like this:
php cline.php firstarg

<?php

$a=5;
$b=3;
echo $a+$b;
?>

The above script echos out 8, so the php file is processed=>
I think, I have got a problem with those argc,argv things.
I also looked in the php.ini file the line: register_argc_argv = On (i thinks its good).

Under windows, i can run these scipts with php-cli.exe(and both of them works),
but under Linux there is no php-cli.
I hope you can understand my problem(explained with my poor english), and I hope someone
got the solution.

Reply With Quote
  #2  
Old August 12th, 2002, 02:35 PM
EvilivE EvilivE is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Milwaukee, WI USA
Posts: 291 EvilivE User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 3
Send a message via Yahoo to EvilivE
RE: commandline + Linux

hmmm ...
I use php cli, however I never passed my cli scripts any arguments.

FYI: those argv and argc things those are "Argument Vector" and "Argument Count", respectively.

From looking at your code, I would say it works as designed! You are checking if argc (argument count) is equal to two and you are calling your script with "php cline.php firstarg" which has an argc of one!

Unless there is some funky way on how php calculates argc, your script works as designed.

HTH

Reply With Quote
  #3  
Old August 12th, 2002, 06:42 PM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 25
RE: commandline + Linux

php cline.php firstarg - in this call argc=2

Copied from the php manual:
$argc and $argv. The first is the number of arguments plus one (the name of the script running). The second is an array containing the arguments, starting with the script name as number zero ($argv[0]).

Anyway I've got a half solution. I turned on notices and get a notice : undefined variable argc
Then I turned register_globals=On and I got the script working.I think there must be a better way, because under windows it runs perfectly with register_globals=Off.

Reply With Quote
Reply

Viewing: Codewalkers ForumsPHP RelatedPHP Installation > commandline + Linux


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump




 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

Request Your Free Technology Downloads!
 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

Request Your Free Technology Downloads!
 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

Request Your Free Technology Downloads!
 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

Request Your Free Technology Downloads!
 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

Request Your Free Technology Downloads!
 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 




© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 3 Hosted by Hostway
For more Enterprise Application Development news, visit eWeek