Weird CLI issue

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Weird CLI issue

Post by Burrito »

I have a cron job set up to run a report every hour on my phonelog system here but for some reason my php page isn't working from the CLI. I get an error like this:

Code: Select all

Warning: fopen(logs/all-tday.php): failed to open stream: No such file or direct
ory in w:\inetpub\wwwroot\phonesys\report.php on line 157

Warning: fwrite(): supplied argument is not a valid stream resource in w:\inetpu
b\wwwroot\phonesys\report.php on line 158

Warning: fclose(): supplied argument is not a valid stream resource in w:\inetpu
b\wwwroot\phonesys\report.php on line 159
the weird thing is, if I run that same page from a web interface, it loads up just perfectly with no errors. It's almost like my relative paths get busted from the CLI, but they remain in tact from the web interface. I have done this exact same thing on another machine and not had problems, but for some reason, it just dies here...

any suggestions?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

make sure the file is being run from the correct start up directory..
Bennettman
Forum Contributor
Posts: 130
Joined: Sat Jun 15, 2002 3:58 pm

Post by Bennettman »

You could try using an absolute path or a URL path.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

Me thinks this is a sceurity policy issue :wink:
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

ok, I just looked at the other machine to see if I could see a difference between how they are set up and as far as I can see they are identical.

I do remember this however: when I set the first machine up initally I used the php installer (so it installed with cgi) I then (after the fact) set it up with isapi for the web part. could it be that the initial install (using the installer) initiated somethign different for the cgi (php.exe) that would make it run differently from the CLI than what I did with the new one (straight isapi from the beginning)?

that's the only thing I can think of at thsi point.
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

well Feyd helped me out by having me run getcwd() from both the cli and the web interface and we determined that it was a different folder location for the two.

Bennet your suggestion was right on and changing it to an absolute path fixed the problem.

I'm still at a loss as to why it would work on the other system though as it's virutally the same.

why would the cwd be the location of the file on the old system, but not the new?

my interest is peaked....anyone know?
Post Reply