Board index   FAQ   Search  
Register  Login
Board index System Administration Server installation and configuration

PHP via Cmd line (Windows Server)

Discuss server installationa nd configuration issues here

Moderators: macek, egami, gesf

PHP via Cmd line (Windows Server)

Postby nanocyte » Sat Dec 17, 2011 3:38 pm

Hi there,

we're running Windows SBS 2008 with IIS7. Our main homepage is a Drupal site. Drupal has a cronjob, which we used to run via Scheduled Tasks with a .bat file.
The .bat file runs the following:
Code: Select all
C:\PHP\php.exe C:\inetpub\wwwroot\cron.php


This worked fine for some time, but now there's a problem. Scheduled Task is still executed at the right time. But the cron.php seems not to run correctly. After some testing, I figured out that include() or require() seems to be the problem. If ran via HTTP no problem, but running in cmd-line the script is stopping when it should include another file. Error log is not reporting anything at all on this... and Google search isn't helpful this time.

Maybe I don't see the wood for the trees, but can someone help me or give a hint?

Regards, nanocyte
nanocyte
New php-forum User
New php-forum User
 
Posts: 5
Joined: Sat Dec 17, 2011 3:19 pm

Re: PHP via Cmd line (Windows Server)

Postby nanocyte » Sun Dec 18, 2011 5:01 pm

Update: exactly, the include seems to work, but the script is stopping, when it should call a function, that is defined in this included file.
nanocyte
New php-forum User
New php-forum User
 
Posts: 5
Joined: Sat Dec 17, 2011 3:19 pm

Re: PHP via Cmd line (Windows Server)

Postby egami » Mon Dec 19, 2011 6:37 am

Try changing the include statement to use the absolute path, instead of the relative path.
User avatar
egami
php-forum GURU
php-forum GURU
 
Posts: 2196
Joined: Wed Oct 06, 2010 11:19 am
Location: Happy Valley, UT

Re: PHP via Cmd line (Windows Server)

Postby nanocyte » Mon Dec 19, 2011 6:52 am

Thanks for your response.
Well, now the cron-script includes the file correctly. But this included file includes several other files -.- Well, I could edit all these include(). But once Drupal is updated the changes will have to be done another time (if there is a newer version). This script was running correctly previously but not any more. Is there an other solution? Maybe changing include path in php.ini or something? What else could effect this behaviour?
nanocyte
New php-forum User
New php-forum User
 
Posts: 5
Joined: Sat Dec 17, 2011 3:19 pm

Re: PHP via Cmd line (Windows Server)

Postby egami » Mon Dec 19, 2011 7:21 am

try putting your script in the same directory as the first include..
User avatar
egami
php-forum GURU
php-forum GURU
 
Posts: 2196
Joined: Wed Oct 06, 2010 11:19 am
Location: Happy Valley, UT

Re: PHP via Cmd line (Windows Server)

Postby nanocyte » Mon Dec 19, 2011 7:37 am

Yes, this will also include the first one... but not the rest.
nanocyte
New php-forum User
New php-forum User
 
Posts: 5
Joined: Sat Dec 17, 2011 3:19 pm

Re: PHP via Cmd line (Windows Server)

Postby nanocyte » Tue Jan 17, 2012 3:54 am

Problem found: For whatever reason, PHP.exe wasn't in the folder as before any more. So I added two lines in my batch script:
Code: Select all
C:
cd /inetpub/wwwroot
C:\php\php.exe C:\inetpub\wwwroot\cron.php

This worked for the includes.

Next problem was this:
includes/common.inc around line 2660 in function _drupal_bootstrap_full(). There's a drupal_set_header('Content-Type: text/html; charset=utf-8'); which caused the execution via command line to stop immediately. Commenting out this line solved the issue. But has anyone an idea why this causes the script to stop when executed in cmd.exe ?
nanocyte
New php-forum User
New php-forum User
 
Posts: 5
Joined: Sat Dec 17, 2011 3:19 pm


Return to Server installation and configuration

Who is online

Users browsing this forum: No registered users and 0 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.

cron