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:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old August 12th, 2002, 01: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: 24
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, 01: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: 2
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, 05: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: 24
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!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five &quot;checkpoints&quot; for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

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





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway