I'm not used to the PHP CLI (always used PHP via http), so maybe it's something simple I'm missing.
The fact is that I can get the PHP CLI working in our production server. However I need to test a process prior to be automated, and there is no way to get it working as expected in the CLI of the development server.
It simply outputs nothing. But no error is displayed either. Even if it's the index.php page, when I do this in the prod. server, the CLI displays the final html. The same index.php displays nothing.
Off hand I can't think why you would get no output. Does something simple from the command line work, like:
Code:
php -r "echo 'Hello, world.'";
?
PS: Just in case, we are talking CLI (command line interface) here and not CGI, right?
"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
~ Terry Pratchett in Nation
a simple echo like that works perfectly (I was talking about the command line interface). That's what keeps me more puzzled.
What might be stopping it to output anything when I run code from a file?
BTW: there is no output because the process is not executed. It must update some data in the DB and create a log, and none of these actions happen.
How are you executing the script? I ran into some issues migrating some CLI scripts from XP to Windows 7 and found that the way paths were determined from cmd.exe had altered a bit (as well as the "default" actions for executables).
well I'm using Linux, and absolute paths so that the execution is not affected by the directory from which the execution takes place. Something like this (I'm using codeigniter and this is the way to execute scripts with it):
The only CLI gotcha I can think of I've run into lately (the last year or so) is that in one instance I had to be sure to cd to the directory of the script I was invoking, as it was calling other scripts relative to its current working directory.
Another thing to check is if it's using a different php.ini file than you think it is (the CLI can potentially use a different one than the ISAPI or other web interface does).
"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
~ Terry Pratchett in Nation
well I'm using Linux, and absolute paths so that the execution is not affected by the directory from which the execution takes place. Something like this (I'm using codeigniter and this is the way to execute scripts with it):
"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
~ Terry Pratchett in Nation
that's right. The CodeIgniter documentation in which I learnt how to invoke a controller method with some parameter.
Since it worked perfectly in production with absolute paths I assumed it had to behave the same in development. Anyway, tomorrow in the office I will try to execute it just from the same directory as index.php, just in case that's the problem.
Or php -l filename.php to see if anything interesting shows up in terms of errors? (That's a lower-case "L", not at number "1".)
"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
~ Terry Pratchett in Nation
Is it having trouble determining if it was a CLI call? Could be a mini-logic error as well. Is the exact same script running in production? Is the file permissions the same as production (for the user executing the script)?
Bookmarks