28, May 2012

php code via the command line on windows - webmaster forum

 
Webdigity webmaster forums
[ Home | Help | Search | Forum's Shop | Archive | Login | Register | Webmaster Directory ]
Webdigity Webmaster Forums  >  Web Development  >  PhP
Topic: php code via the command line on windows
« previous next »
Pages: [1] 2 Print
Instabuck - The easy way to sell digital products online

Author Topic: php code via the command line on windows  (Read 3765 times)
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6691
34714 credits
Members referred : 374


It's time to use PHP5!


« on: Sep 11, 2006, 05:02:24 pm »

Hello,

I need to execute some php code through the command line on windows, like:

from remote a script is executed to post some vars with GET, after these vars are checked this vars need to beused in a scripty which has to be executed throuhj the commanline.

I tried already the dos box and executed this code succesfully:
"php myfile.php"

how to do that via a a script?

I tried this code but nothing is happen:
exec("php myfile.php");

I executed the script via the browser...

I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 5799
46391 credits
Members referred : 3



« Reply #1 on: Sep 11, 2006, 05:19:44 pm »

Maybe CURL?

BTW the exec ("php .... wont work because you don't add the path to the php.exe file.

Trial and Error my two best teachers Cool
Join us @ facebook or twitter

Last blog : Butterfly Marketing 2.0
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6691
34714 credits
Members referred : 374


It's time to use PHP5!


« Reply #2 on: Sep 11, 2006, 08:42:22 pm »

Maybe CURL?

BTW the exec ("php .... wont work because you don't add the path to the php.exe file.
I add the path to the environment, I need to execute a php script (or code) on the command line while on remore a script is called, how to do that with curl?

I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 5799
46391 credits
Members referred : 3



« Reply #3 on: Sep 12, 2006, 07:49:46 am »

Does this helps? (Still I am not sure what you want to do)

Code:
<?php
while ( true )
{
    
//curl the remote script here
}

Trial and Error my two best teachers Cool
Join us @ facebook or twitter

Last blog : Butterfly Marketing 2.0
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6691
34714 credits
Members referred : 374


It's time to use PHP5!


« Reply #4 on: Sep 12, 2006, 08:20:01 am »

Does this helps? (Still I am not sure what you want to do)

Code:
<?php
while ( true )
{
    
//curl the remote script here
}

I can't follow you Wink

It looks like that the script must be executed by CLI and not CGI that's why I need this, since there server oinly need to execute one script I shpuld change the config. Is it possible to run php in cli mode and access the scripts via the browser?

I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 5799
46391 credits
Members referred : 3



« Reply #5 on: Sep 12, 2006, 08:23:55 am »

Hmm, can you explain what you want to do?

Trial and Error my two best teachers Cool
Join us @ facebook or twitter

Last blog : Butterfly Marketing 2.0
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6691
34714 credits
Members referred : 374


It's time to use PHP5!


« Reply #6 on: Sep 12, 2006, 08:49:00 am »

Hmm, can you explain what you want to do?

My script is working (the thumbnail thing) but in some cases it doesn't work via the regular way, But if I run the script via the command line it works fine. (don't ask me why its just a workarround)

I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 5799
46391 credits
Members referred : 3



« Reply #7 on: Sep 12, 2006, 08:52:05 am »

Ok, and when do you want to run it from CLI?

I mean this will be triggered from another php script, or it will be croned?

Trial and Error my two best teachers Cool
Join us @ facebook or twitter

Last blog : Butterfly Marketing 2.0
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6691
34714 credits
Members referred : 374


It's time to use PHP5!


« Reply #8 on: Sep 12, 2006, 08:56:55 am »

Ok, and when do you want to run it from CLI?

I mean this will be triggered from another php script, or it will be croned?

I think I will run this (only) script always in CLI mode or is this bad?

the script will running on request if someone is calling for a thumb...

I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 5799
46391 credits
Members referred : 3



« Reply #9 on: Sep 12, 2006, 08:59:49 am »

try to exec but with both paths. eg.

exec ("c:\php\php.exe c:\htdocs\myscript.php");

Does this works?

Trial and Error my two best teachers Cool
Join us @ facebook or twitter

Last blog : Butterfly Marketing 2.0
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6691
34714 credits
Members referred : 374


It's time to use PHP5!


« Reply #10 on: Sep 12, 2006, 09:08:02 am »

try to exec but with both paths. eg.

exec ("c:\php\php.exe c:\htdocs\myscript.php");

Does this works?

never put a path to the script name, I will try...

I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 5799
46391 credits
Members referred : 3



« Reply #11 on: Sep 12, 2006, 09:09:21 am »

That was the problem I am sure....

Trial and Error my two best teachers Cool
Join us @ facebook or twitter

Last blog : Butterfly Marketing 2.0
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6691
34714 credits
Members referred : 374


It's time to use PHP5!


« Reply #12 on: Sep 12, 2006, 09:13:30 am »

nope doesn't work...

I tried already the system command to echo some text to the browser and this is fine, but executing a complexer script doesn't work

I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 5799
46391 credits
Members referred : 3



« Reply #13 on: Sep 12, 2006, 09:17:50 am »

Maybe the script is using something that wont work from CLI.

Common problems to this is the include path. Try to use the  set_include_path() function in the script that you are executing to assing the correct paths (it wants full paths)

Also check if you are using the $_SERVER variable as this is not working with CLI.

Trial and Error my two best teachers Cool
Join us @ facebook or twitter

Last blog : Butterfly Marketing 2.0
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6691
34714 credits
Members referred : 374


It's time to use PHP5!


« Reply #14 on: Sep 12, 2006, 09:31:17 am »

I understand, the strange thing is it's working fine if I enter that manually in the dos box:

Code:
c:\wwwroot\htdocs\folder>php test.php
« Last Edit: Sep 12, 2006, 09:33:39 am by olaf »

I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 5799
46391 credits
Members referred : 3



« Reply #15 on: Sep 12, 2006, 10:00:24 am »

Maybe your hosting has some restrictions?

Trial and Error my two best teachers Cool
Join us @ facebook or twitter

Last blog : Butterfly Marketing 2.0
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6691
34714 credits
Members referred : 374


It's time to use PHP5!


« Reply #16 on: Sep 12, 2006, 10:16:41 am »

Maybe your hosting has some restrictions?
its on my local server...

is using "exec()" not the same like enter the code to the dos box?

I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 5799
46391 credits
Members referred : 3



« Reply #17 on: Sep 12, 2006, 10:17:25 am »

I think it is the same.

Trial and Error my two best teachers Cool
Join us @ facebook or twitter

Last blog : Butterfly Marketing 2.0
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6691
34714 credits
Members referred : 374


It's time to use PHP5!


« Reply #18 on: Sep 12, 2006, 10:24:02 am »

I think it is the same.
how about a .bat file?

I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 5799
46391 credits
Members referred : 3



« Reply #19 on: Sep 12, 2006, 10:27:46 am »

Try it, and see the results Smiley

Trial and Error my two best teachers Cool
Join us @ facebook or twitter

Last blog : Butterfly Marketing 2.0
Trackback URI for this entry : http://www.webdigity.com/trackback.php?topic=4038
Tags : php browsers hosting php.ini Bookmark this thread : Digg Del.icio.us Dzone more....

Pages: [1] 2 Print 
Webdigity Webmaster Forums  >  Web Development  >  PhP
Topic: php code via the command line on windows
« previous next »
Jump to:
User Area
Welcome, Guest. Please login or register.
Did you miss your activation email?
May 28, 2012, 04:27:04 pm





Login with username, password and session length

Donate to our community, and get a permanent link back to your site!

Donate to our community, and get a permanent link back to your site!






Web Design Gallery · Whois Lookup · Pagerank · Tag Browsing · Lo-fi version · Syndication · Webmaster forum history · Advertise
Developed by HumanWorks © 2005 - 2012 Webdigity webmaster community · sublime directory
Webdigity Webmaster Forums | Powered by SMF 1.0.12. © 2001-2005, Lewis Media. All Rights Reserved.