Re: [PHP] PHP CLI setting cooked terminal mode
On 11 Sep 2013, at 17:37, Alain Williams wrote: > Hi, > > I am running a PHP script at the command line and piping the output through > less: > >./myScript | less > > Since less is an interactive program it puts the terminal into 'raw' mode so > that it can read characters one at a time. However, when I do the above I find > that the commands that I type to less are echoed back to me and not acted on > until I type . This is not as it should be. > > The sript is not doing anything really clever, just looking at a few files and > printing out directory contents, time stamps, ... > > If I run the script under strace I see: > >ioctl(0, SNDCTL_TMR_TIMEBASE or TCGETS, {B38400 opost isig icanon echo > ...}) = 0 >ioctl(0, SNDCTL_TMR_STOP or TCSETSW, {B38400 opost isig icanon echo ...}) > = 0 > > > I can get it to not do this by connect stdout to /dev/null: > >./myScript > /dev/null | less > > another way of getting it to work is (and this shows that it really is PHP > that > is messing the tty modes): > >./myScript > /dev/null | (sleep 10;less) > > However: PHP should not set the terminal to cooked mode in the first place > > Is there any way in which I can get PHP to not do this ? > > TIA > > I am running PHP 5.3.3 on CentOS 6. Make sure output buffering is off by putting this at the top of your script: while(ob_end_clean()); -Stuart -- Stuart Dallas 3ft9 Ltd http://3ft9.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP CLI setting cooked terminal mode
On Wed, Sep 11, 2013 at 05:45:45PM +0100, Stuart Dallas wrote: > On 11 Sep 2013, at 17:37, Alain Williams wrote: > Make sure output buffering is off by putting this at the top of your script: > > while(ob_end_clean()); Sorry, that does not fix the problem - but thanks for trying. -- Alain Williams Linux/GNU Consultant - Mail systems, Web sites, Networking, Programmer, IT Lecturer. +44 (0) 787 668 0256 http://www.phcomp.co.uk/ Parliament Hill Computers Ltd. Registration Information: http://www.phcomp.co.uk/contact.php #include -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php-cli-shebang
Joe Francis wrote: why not using php.exe instead of php-cgi.exe as a parser ? Thanks for pointing that out... didn't have any reasoning, but since your post, I've learned the difference and have changed the script. Donovan -- dbrooke -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php-cli-shebang
why not using php.exe instead of php-cgi.exe as a parser ? On Wed, Jun 8, 2011 at 7:42 AM, Lists wrote: > Lists wrote: > >> Windows Server 2003 >> PHP fastcgi 5.2 >> > > > > O.K. '-q' is quiet mode (no header info), which works better when not using > the -f flag when calling the script (it appears). > > anyway, I solved my issues with a work around, so no worries. > > > Donovan > > > -- > dbrooke > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- Powered By Francis™. Welcome to my website: http://www.francistm.com Rewrite to francis...@gmail.com please.
Re: [PHP] php-cli-shebang
Lists wrote: Windows Server 2003 PHP fastcgi 5.2 O.K. '-q' is quiet mode (no header info), which works better when not using the -f flag when calling the script (it appears). anyway, I solved my issues with a work around, so no worries. Donovan -- dbrooke -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php cli question
Thanks Bostjan for the suggestion. I did raise the issue and here is the reply: http://news.php.net/php.internals/49672 Thx, Ravi On Wed, Sep 15, 2010 at 2:38 AM, Bostjan Skufca wrote: > Here are the results I got when question of migration from apache to nginx > was brought up: > http://blog.a2o.si/2009/06/24/apache-mod_php-compared-to-nginx-php-fpm/ > (BTW there is some FPM in main PHP distribution now) > > As for resource management, I recommend looking at php sources > (Zend/zend_alloca.c:zend_mm_shutdown() specifically) and building a custom > extension that frees discarded memory resources on your request or timer or > sth else. Not sure if it is possible like that but this is just a > suggestion, don't quote me on that :) > Also, for such questions I recommend you to join php-internals mailing list, > it seems more appropriate. > > b. > > > On 15 September 2010 04:19, J Ravi Menon wrote: >> >> On Tue, Sep 14, 2010 at 1:15 PM, Per Jessen wrote: >> > J Ravi Menon wrote: >> > >> >> On Tue, Sep 14, 2010 at 12:43 AM, Per Jessen wrote: >> >>> J Ravi Menon wrote: >> >>> >> Few questions: >> >> 1) Does opcode cache really matter in such cli-based daemons? As >> 'SomeClass' is instantiated at every loop, I am assuming it is only >> compiled once as it has already been 'seen'. >> >>> >> >>> Yup. >> >> >> >> Just to clarify, you mean we don't need the op-code cache here right? >> > >> > That is correct. >> > >> 2) What about garbage collection? In a standard apache-mod-php >> setup, we rely on the end of a request-cycle to free up resources - >> close file descriptiors, free up memory etc.. >> I am assuming in the aforesaid standalone daemon case, we would >> have to do this manually? >> >>> >> >>> Yes. >> >> >> >> So 'unset($some_big_array)' or 'unset($some_big_object)' etc.. is the >> >> right way to go for non-resource based items? i.e. it needs to be >> >> explicitly done? >> > >> > It's not quite like C - if you reassign something, the previous contents >> > are automagically freed. I use unset() if I know it could be a while >> > (hours) before it'll likely be reassigned, but it won't be used in the >> > meantime. >> > >> >> Thanks Per for clarifying this for me. Now on my follow up question: >> >> [Note: I think it is related to the issues discussed above hence >> keeping it on this thread but if I am violating any guidelines here, >> do let me know] >> >> One reason the aforesaid questions got triggered was that in our >> company right now, there is a big discussion on moving away from >> apache+mod_php solution to nginx+fast-cgi based model for handling all >> php-based services. The move seems to be more based some anecdotal >> observations and possibly not based on a typical php-based app (i.e. >> the php script involved was trivial one acting as some proxy to >> another backend service). >> >> I have written fast-cgi servers in the past in C++, and I am aware how >> the apahce<>fast-cgi-servers work (in unix socket setups). All >> our php apps are written with apache+mod_php in mind (no explicit >> resource mgmt ), so this was a concern to me. >> >> If the same scripts now need to run 'forever' as a fastcgi server, are >> we forced to do such manual resource mgmt? Or are there solutions here >> that work just as in mod_php? >> >> This reminded me of the cli daemons that I had written earlier where >> such manual cleanups were done, and hence my doubts on this >> nginx+fast-cgi approach. >> >> thx, >> Ravi >> >> >> > >> > >> > -- >> > Per Jessen, Zürich (14.6°C) >> > >> > >> > -- >> > PHP General Mailing List (http://www.php.net/) >> > To unsubscribe, visit: http://www.php.net/unsub.php >> > >> > >> >> -- >> PHP General Mailing List (http://www.php.net/) >> To unsubscribe, visit: http://www.php.net/unsub.php >> > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php cli question
Here are the results I got when question of migration from apache to nginx was brought up: http://blog.a2o.si/2009/06/24/apache-mod_php-compared-to-nginx-php-fpm/ (BTW there is some FPM in main PHP distribution now) As for resource management, I recommend looking at php sources (Zend/zend_alloca.c:zend_mm_shutdown() specifically) and building a custom extension that frees discarded memory resources on your request or timer or sth else. Not sure if it is possible like that but this is just a suggestion, don't quote me on that :) Also, for such questions I recommend you to join php-internals mailing list, it seems more appropriate. b. On 15 September 2010 04:19, J Ravi Menon wrote: > On Tue, Sep 14, 2010 at 1:15 PM, Per Jessen wrote: > > J Ravi Menon wrote: > > > >> On Tue, Sep 14, 2010 at 12:43 AM, Per Jessen wrote: > >>> J Ravi Menon wrote: > >>> > Few questions: > > 1) Does opcode cache really matter in such cli-based daemons? As > 'SomeClass' is instantiated at every loop, I am assuming it is only > compiled once as it has already been 'seen'. > >>> > >>> Yup. > >> > >> Just to clarify, you mean we don't need the op-code cache here right? > > > > That is correct. > > > 2) What about garbage collection? In a standard apache-mod-php > setup, we rely on the end of a request-cycle to free up resources - > close file descriptiors, free up memory etc.. > I am assuming in the aforesaid standalone daemon case, we would > have to do this manually? > >>> > >>> Yes. > >> > >> So 'unset($some_big_array)' or 'unset($some_big_object)' etc.. is the > >> right way to go for non-resource based items? i.e. it needs to be > >> explicitly done? > > > > It's not quite like C - if you reassign something, the previous contents > > are automagically freed. I use unset() if I know it could be a while > > (hours) before it'll likely be reassigned, but it won't be used in the > > meantime. > > > > Thanks Per for clarifying this for me. Now on my follow up question: > > [Note: I think it is related to the issues discussed above hence > keeping it on this thread but if I am violating any guidelines here, > do let me know] > > One reason the aforesaid questions got triggered was that in our > company right now, there is a big discussion on moving away from > apache+mod_php solution to nginx+fast-cgi based model for handling all > php-based services. The move seems to be more based some anecdotal > observations and possibly not based on a typical php-based app (i.e. > the php script involved was trivial one acting as some proxy to > another backend service). > > I have written fast-cgi servers in the past in C++, and I am aware how > the apahce<>fast-cgi-servers work (in unix socket setups). All > our php apps are written with apache+mod_php in mind (no explicit > resource mgmt ), so this was a concern to me. > > If the same scripts now need to run 'forever' as a fastcgi server, are > we forced to do such manual resource mgmt? Or are there solutions here > that work just as in mod_php? > > This reminded me of the cli daemons that I had written earlier where > such manual cleanups were done, and hence my doubts on this > nginx+fast-cgi approach. > > thx, > Ravi > > > > > > > > -- > > Per Jessen, Zürich (14.6°C) > > > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >
Re: [PHP] php cli question
On Tue, Sep 14, 2010 at 1:15 PM, Per Jessen wrote: > J Ravi Menon wrote: > >> On Tue, Sep 14, 2010 at 12:43 AM, Per Jessen wrote: >>> J Ravi Menon wrote: >>> Few questions: 1) Does opcode cache really matter in such cli-based daemons? As 'SomeClass' is instantiated at every loop, I am assuming it is only compiled once as it has already been 'seen'. >>> >>> Yup. >> >> Just to clarify, you mean we don't need the op-code cache here right? > > That is correct. > 2) What about garbage collection? In a standard apache-mod-php setup, we rely on the end of a request-cycle to free up resources - close file descriptiors, free up memory etc.. I am assuming in the aforesaid standalone daemon case, we would have to do this manually? >>> >>> Yes. >> >> So 'unset($some_big_array)' or 'unset($some_big_object)' etc.. is the >> right way to go for non-resource based items? i.e. it needs to be >> explicitly done? > > It's not quite like C - if you reassign something, the previous contents > are automagically freed. I use unset() if I know it could be a while > (hours) before it'll likely be reassigned, but it won't be used in the > meantime. > Thanks Per for clarifying this for me. Now on my follow up question: [Note: I think it is related to the issues discussed above hence keeping it on this thread but if I am violating any guidelines here, do let me know] One reason the aforesaid questions got triggered was that in our company right now, there is a big discussion on moving away from apache+mod_php solution to nginx+fast-cgi based model for handling all php-based services. The move seems to be more based some anecdotal observations and possibly not based on a typical php-based app (i.e. the php script involved was trivial one acting as some proxy to another backend service). I have written fast-cgi servers in the past in C++, and I am aware how the apahce<>fast-cgi-servers work (in unix socket setups). All our php apps are written with apache+mod_php in mind (no explicit resource mgmt ), so this was a concern to me. If the same scripts now need to run 'forever' as a fastcgi server, are we forced to do such manual resource mgmt? Or are there solutions here that work just as in mod_php? This reminded me of the cli daemons that I had written earlier where such manual cleanups were done, and hence my doubts on this nginx+fast-cgi approach. thx, Ravi > > > -- > Per Jessen, Zürich (14.6°C) > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php cli question
Per Jessen wrote: J Ravi Menon wrote: 2) What about garbage collection? In a standard apache-mod-php setup, we rely on the end of a request-cycle to free up resources - close file descriptiors, free up memory etc.. I am assuming in the aforesaid standalone daemon case, we would have to do this manually? Yes. So 'unset($some_big_array)' or 'unset($some_big_object)' etc.. is the right way to go for non-resource based items? i.e. it needs to be explicitly done? It's not quite like C - if you reassign something, the previous contents are automagically freed. I use unset() if I know it could be a while (hours) before it'll likely be reassigned, but it won't be used in the meantime. Has anybody done a comparison of setting to null rather than unset'ing; does unset invoke the garbage collector instantly? i.e. is unset the best approach to clearing objects from memory quickly? Best, Nathan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php cli question
J Ravi Menon wrote: > On Tue, Sep 14, 2010 at 12:43 AM, Per Jessen wrote: >> J Ravi Menon wrote: >> >>> Few questions: >>> >>> 1) Does opcode cache really matter in such cli-based daemons? As >>> 'SomeClass' is instantiated at every loop, I am assuming it is only >>> compiled once as it has already been 'seen'. >> >> Yup. > > Just to clarify, you mean we don't need the op-code cache here right? That is correct. >>> 2) What about garbage collection? In a standard apache-mod-php >>> setup, we rely on the end of a request-cycle to free up resources - >>> close file descriptiors, free up memory etc.. >>> I am assuming in the aforesaid standalone daemon case, we would >>> have to do this manually? >> >> Yes. > > So 'unset($some_big_array)' or 'unset($some_big_object)' etc.. is the > right way to go for non-resource based items? i.e. it needs to be > explicitly done? It's not quite like C - if you reassign something, the previous contents are automagically freed. I use unset() if I know it could be a while (hours) before it'll likely be reassigned, but it won't be used in the meantime. -- Per Jessen, Zürich (14.6°C) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php cli question
On Tue, Sep 14, 2010 at 12:43 AM, Per Jessen wrote: > J Ravi Menon wrote: > >> Few questions: >> >> 1) Does opcode cache really matter in such cli-based daemons? As >> 'SomeClass' is instantiated at every loop, I am assuming it is only >> compiled once as it has already been 'seen'. > > Yup. Just to clarify, you mean we don't need the op-code cache here right? > >> 2) What about garbage collection? In a standard apache-mod-php setup, >> we rely on the end of a request-cycle to free up resources - close >> file descriptiors, free up memory etc.. >> I am assuming in the aforesaid standalone daemon case, we would >> have to do this manually? > > Yes. > So 'unset($some_big_array)' or 'unset($some_big_object)' etc.. is the right way to go for non-resource based items? i.e. it needs to be explicitly done? thx, Ravi >> Note: I have written pre-forker deamons in php directly and >> successfully deployed them in the past, but never looked at in depth >> to understand all the nuances. Anecdotally, I have >> done 'unset()' at some critical places were large arrays were used, >> and I think it helped. AFAIK, unlike Java, there is no 'garbage >> collector' thread that does all the magic? > > Correct. > > > > -- > Per Jessen, Zürich (12.9°C) > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php cli question
J Ravi Menon wrote: > Few questions: > > 1) Does opcode cache really matter in such cli-based daemons? As > 'SomeClass' is instantiated at every loop, I am assuming it is only > compiled once as it has already been 'seen'. Yup. > 2) What about garbage collection? In a standard apache-mod-php setup, > we rely on the end of a request-cycle to free up resources - close > file descriptiors, free up memory etc.. > I am assuming in the aforesaid standalone daemon case, we would > have to do this manually? Yes. > Note: I have written pre-forker deamons in php directly and > successfully deployed them in the past, but never looked at in depth > to understand all the nuances. Anecdotally, I have > done 'unset()' at some critical places were large arrays were used, > and I think it helped. AFAIK, unlike Java, there is no 'garbage > collector' thread that does all the magic? Correct. -- Per Jessen, Zürich (12.9°C) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php-cli
On 15 March 2010 00:27, Rick Pasotto wrote: > On Sun, Mar 14, 2010 at 08:40:51PM +, Ashley Sheridan wrote: >> On Sun, 2010-03-14 at 16:41 -0400, Rick Pasotto wrote: >> >> > On Sun, Mar 14, 2010 at 06:13:24PM +, Ashley Sheridan wrote: >> > > On Sun, 2010-03-14 at 14:15 -0400, Rick Pasotto wrote: >> > > >> > > > Has cli php changed recently? >> > > > >> > > > I've got a php script (script1) that creates a php script (script2) by >> > > > opening a file and then writing to it. When I try to run it from the >> > > > command line script1 is simply copied to stdout. When I run it from the >> > > > browser it works as expected. The directory has 777 permissions so that >> > > > should not be the problem. >> > > > >> > > > Any ideas? >> > > >> > > How are you running it from the command line? >> > >> > Is there more than one way? I suppose with and without the -f could >> > count as two ways, but the man page says without defaults to with so >> > they're really the same. >> >> Well you havn't given an example, and just say you're calling the script >> from command line and it's outputting the script there. Are you maybe >> just calling the php file without calling php first? > > Of course not. php scripts are not executable. If I had tried to execute > it directly the shell would have told me that. If I had then set the > executable bit the shell would have tried to execute the contents of the > file and the shell would have given several error messages. > > I repeat: is there more than one way to run a php script from the cli? > > -- > "Feeling sorry for yourself, and you present condition, is not only a > waste of energy but the worst habit you could possibly have." > -- Dale Carnegie > Rick Pasotto r...@niof.net http://www.niof.net > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > Be careful. .BAT files are not executable, but you don't need to put the command line processor in front do you? You can quite easily turn ... C:\PHP5\PHP.exe -f C:\Pathed\Directory\Script.php -- -script_arg1 -script_arg2 into Script -script_arg1 -script_arg2 No php.exe, no .php, no -f See http://docs.php.net/manual/en/install.windows.commandline.php You can even turn php scripts into filters ... Script -script_arg1 -script_arg2 | Script2 -script_arg1 -script_arg2 sort of thing. -- - Richard Quadling "Standing on the shoulders of some very clever giants!" EE : http://www.experts-exchange.com/M_248814.html EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731 ZOPA : http://uk.zopa.com/member/RQuadling -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php-cli
On Mon, Mar 15, 2010 at 02:35:54PM +1300, Dmitry Ruban wrote: > Rick Pasotto wrote: > >On Mon, Mar 15, 2010 at 01:32:24PM +1300, Dmitry Ruban wrote: > >>Rick Pasotto wrote: > >>>I repeat: is there more than one way to run a php script from the cli? > >>> > >>On *nix, you can add "#!/usr/bin/php" as first line and make file > >>executable (chmod +x). > > > >Functionally the same. php is still interpreting the script. The script > >is still not an executable. > > > >And, of course, the results are the same. > > > >The problem is that php is *not* interpreting the script. It's acting > >like 'cat'. > > > > It sounds like you may use short tags " in your cli php.ini Thank you. That was the problem. Looks like I've got a habit to change and a lot of file maintenance to do. -- "There are two tragedies in life. One is to lose your heart's desire. The other is to gain it." -- George Bernard Shaw Rick Pasottor...@niof.nethttp://www.niof.net -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php-cli
Rick Pasotto wrote: On Mon, Mar 15, 2010 at 01:32:24PM +1300, Dmitry Ruban wrote: Rick Pasotto wrote: I repeat: is there more than one way to run a php script from the cli? On *nix, you can add "#!/usr/bin/php" as first line and make file executable (chmod +x). Functionally the same. php is still interpreting the script. The script is still not an executable. And, of course, the results are the same. The problem is that php is *not* interpreting the script. It's acting like 'cat'. It sounds like you may use short tags "your cli php.ini What does it show: php -r 'phpinfo();' | grep short -- Dmitry -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php-cli
On Sun, 2010-03-14 at 21:24 -0400, Rick Pasotto wrote: > On Mon, Mar 15, 2010 at 01:32:24PM +1300, Dmitry Ruban wrote: > > Rick Pasotto wrote: > > > > > >I repeat: is there more than one way to run a php script from the cli? > > > > > > > On *nix, you can add "#!/usr/bin/php" as first line and make file > > executable (chmod +x). > > Functionally the same. php is still interpreting the script. The script > is still not an executable. > > And, of course, the results are the same. > > The problem is that php is *not* interpreting the script. It's acting > like 'cat'. > > -- > "There are two tragedies in life. One is to lose your heart's desire. > The other is to gain it." -- George Bernard Shaw > Rick Pasottor...@niof.nethttp://www.niof.net > Have you looked at the error log? Is the php-cli package installed correctly? Thanks, Ash http://www.ashleysheridan.co.uk
Re: [PHP] php-cli
On Mon, Mar 15, 2010 at 01:32:24PM +1300, Dmitry Ruban wrote: > Rick Pasotto wrote: > > > >I repeat: is there more than one way to run a php script from the cli? > > > > On *nix, you can add "#!/usr/bin/php" as first line and make file > executable (chmod +x). Functionally the same. php is still interpreting the script. The script is still not an executable. And, of course, the results are the same. The problem is that php is *not* interpreting the script. It's acting like 'cat'. -- "There are two tragedies in life. One is to lose your heart's desire. The other is to gain it." -- George Bernard Shaw Rick Pasottor...@niof.nethttp://www.niof.net -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php-cli
On Sun, 2010-03-14 at 20:27 -0400, Rick Pasotto wrote: > On Sun, Mar 14, 2010 at 08:40:51PM +, Ashley Sheridan wrote: > > On Sun, 2010-03-14 at 16:41 -0400, Rick Pasotto wrote: > > > > > On Sun, Mar 14, 2010 at 06:13:24PM +, Ashley Sheridan wrote: > > > > On Sun, 2010-03-14 at 14:15 -0400, Rick Pasotto wrote: > > > > > > > > > Has cli php changed recently? > > > > > > > > > > I've got a php script (script1) that creates a php script (script2) by > > > > > opening a file and then writing to it. When I try to run it from the > > > > > command line script1 is simply copied to stdout. When I run it from > > > > > the > > > > > browser it works as expected. The directory has 777 permissions so > > > > > that > > > > > should not be the problem. > > > > > > > > > > Any ideas? > > > > > > > > How are you running it from the command line? > > > > > > Is there more than one way? I suppose with and without the -f could > > > count as two ways, but the man page says without defaults to with so > > > they're really the same. > > > > Well you havn't given an example, and just say you're calling the script > > from command line and it's outputting the script there. Are you maybe > > just calling the php file without calling php first? > > Of course not. php scripts are not executable. If I had tried to execute > it directly the shell would have told me that. If I had then set the > executable bit the shell would have tried to execute the contents of the > file and the shell would have given several error messages. > > I repeat: is there more than one way to run a php script from the cli? > > -- > "Feeling sorry for yourself, and you present condition, is not only a > waste of energy but the worst habit you could possibly have." > -- Dale Carnegie > Rick Pasottor...@niof.nethttp://www.niof.net > I was just asking how you were running it, and havn't been given a straight answer yet, so I'll assume you're doing something like this: php /var/www/html/script.php Thanks, Ash http://www.ashleysheridan.co.uk
Re: [PHP] php-cli
Rick Pasotto wrote: On Sun, Mar 14, 2010 at 08:40:51PM +, Ashley Sheridan wrote: On Sun, 2010-03-14 at 16:41 -0400, Rick Pasotto wrote: On Sun, Mar 14, 2010 at 06:13:24PM +, Ashley Sheridan wrote: On Sun, 2010-03-14 at 14:15 -0400, Rick Pasotto wrote: Has cli php changed recently? I've got a php script (script1) that creates a php script (script2) by opening a file and then writing to it. When I try to run it from the command line script1 is simply copied to stdout. When I run it from the browser it works as expected. The directory has 777 permissions so that should not be the problem. Any ideas? How are you running it from the command line? Is there more than one way? I suppose with and without the -f could count as two ways, but the man page says without defaults to with so they're really the same. Well you havn't given an example, and just say you're calling the script from command line and it's outputting the script there. Are you maybe just calling the php file without calling php first? Of course not. php scripts are not executable. If I had tried to execute it directly the shell would have told me that. If I had then set the executable bit the shell would have tried to execute the contents of the file and the shell would have given several error messages. I repeat: is there more than one way to run a php script from the cli? On *nix, you can add "#!/usr/bin/php" as first line and make file executable (chmod +x). -- Dmitry -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php-cli
On Sun, Mar 14, 2010 at 08:40:51PM +, Ashley Sheridan wrote: > On Sun, 2010-03-14 at 16:41 -0400, Rick Pasotto wrote: > > > On Sun, Mar 14, 2010 at 06:13:24PM +, Ashley Sheridan wrote: > > > On Sun, 2010-03-14 at 14:15 -0400, Rick Pasotto wrote: > > > > > > > Has cli php changed recently? > > > > > > > > I've got a php script (script1) that creates a php script (script2) by > > > > opening a file and then writing to it. When I try to run it from the > > > > command line script1 is simply copied to stdout. When I run it from the > > > > browser it works as expected. The directory has 777 permissions so that > > > > should not be the problem. > > > > > > > > Any ideas? > > > > > > How are you running it from the command line? > > > > Is there more than one way? I suppose with and without the -f could > > count as two ways, but the man page says without defaults to with so > > they're really the same. > > Well you havn't given an example, and just say you're calling the script > from command line and it's outputting the script there. Are you maybe > just calling the php file without calling php first? Of course not. php scripts are not executable. If I had tried to execute it directly the shell would have told me that. If I had then set the executable bit the shell would have tried to execute the contents of the file and the shell would have given several error messages. I repeat: is there more than one way to run a php script from the cli? -- "Feeling sorry for yourself, and you present condition, is not only a waste of energy but the worst habit you could possibly have." -- Dale Carnegie Rick Pasottor...@niof.nethttp://www.niof.net -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php-cli
On Sun, 2010-03-14 at 16:41 -0400, Rick Pasotto wrote: > On Sun, Mar 14, 2010 at 06:13:24PM +, Ashley Sheridan wrote: > > On Sun, 2010-03-14 at 14:15 -0400, Rick Pasotto wrote: > > > > > Has cli php changed recently? > > > > > > I've got a php script (script1) that creates a php script (script2) by > > > opening a file and then writing to it. When I try to run it from the > > > command line script1 is simply copied to stdout. When I run it from the > > > browser it works as expected. The directory has 777 permissions so that > > > should not be the problem. > > > > > > Any ideas? > > > > How are you running it from the command line? > > Is there more than one way? I suppose with and without the -f could > count as two ways, but the man page says without defaults to with so > they're really the same. > > -- > "Remember, today is the tomorrow you worried about yesterday." > -- Dale Carnegie > Rick Pasottor...@niof.nethttp://www.niof.net > Well you havn't given an example, and just say you're calling the script from command line and it's outputting the script there. Are you maybe just calling the php file without calling php first? Thanks, Ash http://www.ashleysheridan.co.uk
Re: [PHP] php-cli
On Sun, Mar 14, 2010 at 06:13:24PM +, Ashley Sheridan wrote: > On Sun, 2010-03-14 at 14:15 -0400, Rick Pasotto wrote: > > > Has cli php changed recently? > > > > I've got a php script (script1) that creates a php script (script2) by > > opening a file and then writing to it. When I try to run it from the > > command line script1 is simply copied to stdout. When I run it from the > > browser it works as expected. The directory has 777 permissions so that > > should not be the problem. > > > > Any ideas? > > How are you running it from the command line? Is there more than one way? I suppose with and without the -f could count as two ways, but the man page says without defaults to with so they're really the same. -- "Remember, today is the tomorrow you worried about yesterday." -- Dale Carnegie Rick Pasottor...@niof.nethttp://www.niof.net -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php-cli
On Sun, 2010-03-14 at 14:15 -0400, Rick Pasotto wrote: > Has cli php changed recently? > > I've got a php script (script1) that creates a php script (script2) by > opening a file and then writing to it. When I try to run it from the > command line script1 is simply copied to stdout. When I run it from the > browser it works as expected. The directory has 777 permissions so that > should not be the problem. > > Any ideas? > > -- > "Whatever the immediate gains and losses, the dangers to our safety > arising from political suppression are always greater than the dangers > to that safety resulting from political freedom. Suppression is always > foolish. Freedom is always wise." -- Alexander Meiklejohn, 1955 > Rick Pasottor...@niof.nethttp://www.niof.net > How are you running it from the command line? Thanks, Ash http://www.ashleysheridan.co.uk
Re: [PHP] Php-cli, scripts freeze on exit
On Sun, Jan 24, 2010 at 16:16, David W. Allor wrote: > Hi! > > I'm using php-cli 5.3.1. > > When I run php from the command line, the script does not return me to > the command prompt when exited. The script always completes, but it has > to be killed to release it's resources. > > I've created a little working example: > > > #!/usr/bin/php > echo 'hellu'; > exit(0); > ?> > > > I execute the script by running "./test.php" > > The script outputs "hellu" and then stops. It does not return to the > command prompt. The only way back is to kill the script. > > This problem does not occur on my remote server, only on my home > environment. I have home-network maintenance scripts that execute other > scripts. If the executed script doesn't exit, the main scripts don't > continue. > > I did a trace, and it turns out that the script is stopping on a futex > wait. > do you have ubuntu home? Does other programs freez? I had the same problem with ubuntu once... but rather than fixing it, I decided to install fedora xD It has something to do with multithreading, but i'm no expert in that. Some suggest deactivating Assistive Technologies: http://ubuntuforums.org/showthread.php?p=6144521 Greetings ;) > > Thanks, > David W. Allor > -- Mailed by: UnReAl4U - unreal4u ICQ #: 54472056 www1: http://www.chw.net/ www2: http://unreal4u.com/
Re: [PHP] Php-cli, scripts freeze on exit
On Mon, Jan 25, 2010 at 1:16 AM, David W. Allor wrote: > Hi! > > I'm using php-cli 5.3.1. > > When I run php from the command line, the script does not return me to > the command prompt when exited. The script always completes, but it has > to be killed to release it's resources. > > I've created a little working example: > > > #!/usr/bin/php > echo 'hellu'; > exit(0); > ?> What if you dont use any exit(0) ?? -- Shiplu Mokaddim My talks, http://talk.cmyweb.net Follow me, http://twitter.com/shiplu SUST Programmers, http://groups.google.com/group/p2psust Innovation distinguishes bet ... ... (ask Steve Jobs the rest) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP CLI vs WebServed
Replying this back on the list, unchanged and without any additions from me yet. On Sat, Apr 25, 2009 at 14:09, Simon wrote: >> Perhaps you may want to consider hacking PHP itself. From memory, >> one place you may want to start looking is the >> php_filter_get_storage() function, then trace back from there. If >> memory continues to serve correctly, it should be in the >> `ext/filter/filter.c` file. > > Hacking php is probably the most efficient solution, but until i can > accomplish that, i think i got a good idea... > > what if i opened a socket to php with C function popen(), this enables > to read/write to the stdin/out of the called program (php). I would > execute php to read the code from stdin, and the first few lines would > be created by my 'webserver' and would just set all the correct > superglobals ($_GET, $_POST, $_SERVER, etc) overwritting whatever is > in there with the correct information. Then i would add one last line > with something like: > require('theRealPHPfile.php'); > this one would be executed with the proper superglobals set. > > the result would give something similar to: > $_GET['somevar'] = 'somevalue'; > // [...] more superglobals set here... > require('index.php'); > ?> > (end of example) > This is what my program would do when someone tries to browse to: > website.com/index.php?somevar=somevalue > > I see a loss of performance for creating the header, but other than > this, i think it should be almost as efficient as hacking php... and > being easier... > > What do you guys think? > > Thanks! > -- daniel.br...@parasane.net || danbr...@php.net http://www.parasane.net/ || http://www.pilotpig.net/ 50% Off All Shared Hosting Plans at PilotPig: Use Coupon DOW1 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP CLI vs WebServed
On Sat, Apr 25, 2009 at 10:14, Simon wrote: > > Hopefully, I'm looking for a way that would not require any hacking of > the PHP files that are currently working with other webservers... Perhaps you may want to consider hacking PHP itself. From memory, one place you may want to start looking is the php_filter_get_storage() function, then trace back from there. If memory continues to serve correctly, it should be in the `ext/filter/filter.c` file. -- daniel.br...@parasane.net || danbr...@php.net http://www.parasane.net/ || http://www.pilotpig.net/ 50% Off All Shared Hosting Plans at PilotPig: Use Coupon DOW1 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP CLI vs WebServed
Thanks for the reply Richard! > Never done this, but could you set environment variables, which would > then be picked up by PHP (and stuffed in $_ENV)? This seems like a good idea, if i mix this with the popen() idea, i wouldnt need /dev/shm or any files at all then... but the problem remains that the PHP code will need to be setup to get its querystring (and other web-related data) in the $_ENV global instead of whatever was done before (ie using $_GET, $_COOKIES, etc...) I could create a simple function that would set all these globals correctly, copying the info from $_ENV to the proper global var. This function would need to be placed at the begining of any 'main' php files (ie index.php but not in the files it includes). Hopefully, I'm looking for a way that would not require any hacking of the PHP files that are currently working with other webservers... Thanks! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP CLI vs WebServed
Hi, >... Never done this, but could you set environment variables, which would then be picked up by PHP (and stuffed in $_ENV)? -- Richard Heyes HTML5 graphing: RGraph (www.rgraph.net) PHP mail: RMail (www.phpguru.org/rmail) PHP datagrid: RGrid (www.phpguru.org/rgrid) PHP Template: RTemplate (www.phpguru.org/rtemplate) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP-CLI issue
On Wed, 2009-03-18 at 06:52 -0700, jesse.ha...@arvatousa.com wrote: > private function getSelection() { > > fwrite(STDOUT,"Mode: "); > > $input = strtoupper(fgetc(STDIN)); > > return $input; > > } Use fgets() instead of fgetc(). You're retrieving one character at a time. When someone hits enter... 1 (or in winblows 2) extra characters are usually put on the input stack that represent the enter key itself. Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] PHP-CLI issue
Rob, Works like a charm! Much appreciated. Thanks, Jesse Hazen -Original Message- From: Robert Cummings [mailto:rob...@interjinn.com] Sent: Wednesday, March 18, 2009 7:24 AM To: Hazen, Jesse, arvato digital services llc Cc: php-general@lists.php.net Subject: RE: [PHP] PHP-CLI issue On Wed, 2009-03-18 at 07:10 -0700, jesse.ha...@arvatousa.com wrote: > Rob, > > Thanks for the quick reply. I did try that before, but now my issue is > that the if-else section does not recognize the data as being valid. So, > I changed it to fgets(), and reran, this time using valid data. The > initial problem is corrected (it only gives the error once), but now it > does not recognize my data, and I get the error once no matter what I > input. Is there anything in particular I would need to do to the > variable, after the STDIN, to prepare it for the validation? Use trim() to trim the retrieved input since it will have the newline appended to it. Then you can do your comparison. Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] PHP-CLI issue
On Wed, 2009-03-18 at 07:10 -0700, jesse.ha...@arvatousa.com wrote: > Rob, > > Thanks for the quick reply. I did try that before, but now my issue is > that the if-else section does not recognize the data as being valid. So, > I changed it to fgets(), and reran, this time using valid data. The > initial problem is corrected (it only gives the error once), but now it > does not recognize my data, and I get the error once no matter what I > input. Is there anything in particular I would need to do to the > variable, after the STDIN, to prepare it for the validation? Use trim() to trim the retrieved input since it will have the newline appended to it. Then you can do your comparison. Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] PHP-CLI issue
Rob, Thanks for the quick reply. I did try that before, but now my issue is that the if-else section does not recognize the data as being valid. So, I changed it to fgets(), and reran, this time using valid data. The initial problem is corrected (it only gives the error once), but now it does not recognize my data, and I get the error once no matter what I input. Is there anything in particular I would need to do to the variable, after the STDIN, to prepare it for the validation? Thanks, Jesse Hazen -Original Message- From: Robert Cummings [mailto:rob...@interjinn.com] Sent: Wednesday, March 18, 2009 7:00 AM To: Hazen, Jesse, arvato digital services llc Cc: php-general@lists.php.net Subject: Re: [PHP] PHP-CLI issue On Wed, 2009-03-18 at 06:52 -0700, jesse.ha...@arvatousa.com wrote: > private function getSelection() { > > fwrite(STDOUT,"Mode: "); > > $input = strtoupper(fgetc(STDIN)); > > return $input; > > } Use fgets() instead of fgetc(). You're retrieving one character at a time. When someone hits enter... 1 (or in winblows 2) extra characters are usually put on the input stack that represent the enter key itself. Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php cli memory leak error
Lewis Wright schreef: > 2009/2/19 Jochem Maas : >> Thodoris schreef: seems to work fine here. What are your php.ini (memory related) settings? run: /usr/local/bin/php --ini and get the location of the php.ini file that is getting used. Check our the memory settings in that file. >>> Some general options: >>> max_input_time = 60 >>> max_execution_time = 120 >>> memory_limit = 128M >>> >>> and the last one I have just noticed (that is why it reports the leak): >>> >>> report_memleaks = On >>> >>> In case I set this to Off it just stops bugging me. But is there a >>> memory leak? >> yes. >> >>> And if yes should I report this as a bug ? >> if ( >> >>1. report_memleaks is a core php.ini setting (not suhosin) (I don't >> recall) >>2. you still get the leak if you disable suhosin extension >>3. you can create a small reproduction script (seems you have one, >> but I'd >> check that it's the getopt() call that triggers the leak) >>4. you can show the mem leak in 5.2.9RC2 and/or php5.3dev >> ) { >>report_a_bug(); >> } >> > > Syntax error, unexpected T_STRING :( > sorry. try this instead: http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php cli memory leak error
2009/2/19 Jochem Maas : > Thodoris schreef: >>> >>> >>> seems to work fine here. >>> >>> What are your php.ini (memory related) settings? >>> >>> run: >>> >>> /usr/local/bin/php --ini >>> >>> and get the location of the php.ini file that is getting used. Check >>> our the memory settings in that file. >>> >>> >>> >>> >> >> Some general options: >> max_input_time = 60 >> max_execution_time = 120 >> memory_limit = 128M >> >> and the last one I have just noticed (that is why it reports the leak): >> >> report_memleaks = On >> >> In case I set this to Off it just stops bugging me. But is there a >> memory leak? > > yes. > >> And if yes should I report this as a bug ? > > if ( > >1. report_memleaks is a core php.ini setting (not suhosin) (I don't > recall) >2. you still get the leak if you disable suhosin extension >3. you can create a small reproduction script (seems you have one, but > I'd > check that it's the getopt() call that triggers the leak) >4. you can show the mem leak in 5.2.9RC2 and/or php5.3dev > ) { >report_a_bug(); > } > Syntax error, unexpected T_STRING :( -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php cli memory leak error
Thodoris schreef: >> >> >> seems to work fine here. >> >> What are your php.ini (memory related) settings? >> >> run: >> >> /usr/local/bin/php --ini >> >> and get the location of the php.ini file that is getting used. Check >> our the memory settings in that file. >> >> >> >> > > Some general options: > max_input_time = 60 > max_execution_time = 120 > memory_limit = 128M > > and the last one I have just noticed (that is why it reports the leak): > > report_memleaks = On > > In case I set this to Off it just stops bugging me. But is there a > memory leak? yes. > And if yes should I report this as a bug ? if ( 1. report_memleaks is a core php.ini setting (not suhosin) (I don't recall) 2. you still get the leak if you disable suhosin extension 3. you can create a small reproduction script (seems you have one, but I'd check that it's the getopt() call that triggers the leak) 4. you can show the mem leak in 5.2.9RC2 and/or php5.3dev ) { report_a_bug(); } > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php cli memory leak error
seems to work fine here. What are your php.ini (memory related) settings? run: /usr/local/bin/php --ini and get the location of the php.ini file that is getting used. Check our the memory settings in that file. Some general options: max_input_time = 60 max_execution_time = 120 memory_limit = 128M and the last one I have just noticed (that is why it reports the leak): report_memleaks = On In case I set this to Off it just stops bugging me. But is there a memory leak? And if yes should I report this as a bug ? -- Thodoris
Re: [PHP] php cli memory leak error
Thodoris wrote: > >> Thodoris wrote: >> >>> Hi gang, >>>I am trying to run a simple PHP script using the cli and I get a >>> weird memory leak error. The script goes like this: >>> >>> #! /usr/local/bin/php >>> >> // Get command line options >>> $options = getopt("f:d:o:"); >>> >>> // Print them out >>> print_r($options); >>> >>> // Clear the array >>> unset($options); >>> ?> >>> >>> The problem is that when I run the script I get this error: >>> Script: './bcom.php' >>> /usr/ports/lang/php5/work/php-5.2.8/main/main.c(2015) : Freeing >>> 0x2871F2A8 (43 bytes), script=./bcom.php >>> === Total 1 memory leaks detected === >>> >>> This is hosted on a FreeBSD 7 machine with: >>> PHP 5.2.8 with Suhosin-Patch 0.9.6.3 (cli) >>> >>> Anyone knows what is happening ?? >>> I have to mention that the array is printed as expected. >>> >>> >> >> how are you call it? What arguments are you passing? etc... >> >> Show us your command line params... >> >> > > I am calling it from the command line like this: > > ./bcom.php -f test -d test -o test > > :-) > > But it really doesn't matter because it seems to leak even when calling > it without passing options. > seems to work fine here. What are your php.ini (memory related) settings? run: /usr/local/bin/php --ini and get the location of the php.ini file that is getting used. Check our the memory settings in that file. -- Jim Lucas "Some men are born to greatness, some achieve greatness, and some have greatness thrust upon them." Twelfth Night, Act II, Scene V by William Shakespeare -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php cli memory leak error
Thodoris wrote: Hi gang, I am trying to run a simple PHP script using the cli and I get a weird memory leak error. The script goes like this: #! /usr/local/bin/php The problem is that when I run the script I get this error: Script: './bcom.php' /usr/ports/lang/php5/work/php-5.2.8/main/main.c(2015) : Freeing 0x2871F2A8 (43 bytes), script=./bcom.php === Total 1 memory leaks detected === This is hosted on a FreeBSD 7 machine with: PHP 5.2.8 with Suhosin-Patch 0.9.6.3 (cli) Anyone knows what is happening ?? I have to mention that the array is printed as expected. how are you call it? What arguments are you passing? etc... Show us your command line params... I am calling it from the command line like this: ./bcom.php -f test -d test -o test :-) But it really doesn't matter because it seems to leak even when calling it without passing options. -- Thodoris
Re: [PHP] php cli memory leak error
Thodoris wrote: > Hi gang, >I am trying to run a simple PHP script using the cli and I get a > weird memory leak error. The script goes like this: > > #! /usr/local/bin/php > // Get command line options > $options = getopt("f:d:o:"); > > // Print them out > print_r($options); > > // Clear the array > unset($options); > ?> > > The problem is that when I run the script I get this error: > Script: './bcom.php' > /usr/ports/lang/php5/work/php-5.2.8/main/main.c(2015) : Freeing > 0x2871F2A8 (43 bytes), script=./bcom.php > === Total 1 memory leaks detected === > > This is hosted on a FreeBSD 7 machine with: > PHP 5.2.8 with Suhosin-Patch 0.9.6.3 (cli) > > Anyone knows what is happening ?? > I have to mention that the array is printed as expected. > how are you call it? What arguments are you passing? etc... Show us your command line params... -- Jim Lucas "Some men are born to greatness, some achieve greatness, and some have greatness thrust upon them." Twelfth Night, Act II, Scene V by William Shakespeare -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Php CLI Parser not working
Did you check what Jim suggested, as well, about short_open_tags? If your scripts use PHP tags like this: Yes, that was the problem - it was Off in: /etc/php5/cli/php.ini we had checked the one in: ./etc/php5/apache2/php.ini and it was On there so we thought something else was wrong. Thanks to you both for your help. - Joel -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Php CLI Parser not working
On Wed, Jul 30, 2008 at 4:53 PM, JJB <[EMAIL PROTECTED]> wrote: > > Hi Daniel, > > We are running like: > php mailscript.php > > The version: > > php-v > > PHP 5.2.5 with Suhosin-Patch 0.9.6.2 (cli) (built: Dec 12 2007 03:51:56) Did you check what Jim suggested, as well, about short_open_tags? If your scripts use PHP tags like this: Better prices on dedicated servers: Intel 2.4GHz/60GB/512MB/2TB $49.99/mo. Intel 3.06GHz/80GB/1GB/2TB $59.99/mo. Dedicated servers, VPS, and hosting from $2.50/mo. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Php CLI Parser not working
Daniel Brown wrote: On Tue, Jul 29, 2008 at 2:19 PM, JJB <[EMAIL PROTECTED]> wrote: We recently rebuilt a webserver and upgraded it to opensuse 10.3. Now, when our webdev people run command line php scripts all of the included files are being output to the terminal instead of parsed. How are the scripts being run from the CLI? As shell scripts with this as the following line: #!/path/to/php -or- #!/bin/env php or by using the command 'php script.php' from the command line? What do you see when, from the command line, you issue the command 'php -v' ? Hi Daniel, We are running like: php mailscript.php The version: php-v PHP 5.2.5 with Suhosin-Patch 0.9.6.2 (cli) (built: Dec 12 2007 03:51:56) Copyright (c) 1997-2007 The PHP Group Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Php CLI Parser not working
JJB wrote: We recently rebuilt a webserver and upgraded it to opensuse 10.3. Now, when our webdev people run command line php scripts all of the included files are being output to the terminal instead of parsed. Can anyone make a good suggestion for what might be going on here? My Linux admin is out today, if someone can give me a clue about what might be the problem, then perhaps I can figure out how to fix it. - Joel If this is a fresh install, you might check to see of the code uses short php tags 'the short_open_tag = Off to short_open_tag = On in your php.ini file. Older versions of PHP had this On by default. Newer versions do not. -- Jim Lucas "Some men are born to greatness, some achieve greatness, and some have greatness thrust upon them." Twelfth Night, Act II, Scene V by William Shakespeare -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Php CLI Parser not working
On Tue, Jul 29, 2008 at 2:19 PM, JJB <[EMAIL PROTECTED]> wrote: > We recently rebuilt a webserver and upgraded it to opensuse 10.3. > Now, when our webdev people run command line php scripts all of the > included files are being output to the terminal instead of parsed. How are the scripts being run from the CLI? As shell scripts with this as the following line: #!/path/to/php -or- #!/bin/env php or by using the command 'php script.php' from the command line? What do you see when, from the command line, you issue the command 'php -v' ? -- Better prices on dedicated servers: Intel 2.4GHz/60GB/512MB/2TB $49.99/mo. Intel 3.06GHz/80GB/1GB/2TB $59.99/mo. Dedicated servers, VPS, and hosting from $2.50/mo. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP-CLI and the "less" command (kubuntu)
Stut wrote: On 2 Jul 2008, at 02:58, Mattias Thorslund wrote: Hi everyone, I have a CLI application that produces lots of output to the terminal, so I like to send the output along to the "less" command. This has always worked very nicely. Moving to the top or bottom of the output used to require just hitting the "home" or "end" key, and the up and down arrows as well as page up and page down worked nicely. After upgrading to Hardy on Kubuntu, the behavior changed. Now, it seems to preempt the navigation and instead print ugly codes for each press on a "navigational key" (one of those mentioned above), such as ^[OF. When I press "enter", the desired scroll is executed. Scrolling up and down is one thing, but it's particularly a pain when trying to search through the output, as it would no longer look up previous search arguments. I thought at first it's a problem with Konsole, my terminal program, or with "less" itself. But I've now tried in different terminal programs, and reading output other than output from PHP, and the ONLY time it happens is when I pipe output from PHP to "less". I have added a small test script that exhibits the problem on my system. It may work well the first time, but when repeating the same command a second time, the "weird" behavior starts. It could very well be some kind of problem with "less", but since I can only reproduce the problem with output from PHP CLI, I thought it's worth asking here. Did something about PHP CLI output change lately? This has nothing to do with PHP. The keystrokes are processed by less so your problem lies there or more likely with the terminal emulation you're using. Please try a more relevant list. -Stut I agree the keystrokes are processed by less. This is probably more a problem with "less". Yes I will ask on other lists as well. I thought it was irrelevant to PHP until I tried to provoke the same behavior by reading large files or other console input. Nope, only PHP output does it, so I figured someone here might have encountered this behavior too. Mattias Maybe you didn't -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP-CLI and the "less" command (kubuntu)
On 2 Jul 2008, at 02:58, Mattias Thorslund wrote: Hi everyone, I have a CLI application that produces lots of output to the terminal, so I like to send the output along to the "less" command. This has always worked very nicely. Moving to the top or bottom of the output used to require just hitting the "home" or "end" key, and the up and down arrows as well as page up and page down worked nicely. After upgrading to Hardy on Kubuntu, the behavior changed. Now, it seems to preempt the navigation and instead print ugly codes for each press on a "navigational key" (one of those mentioned above), such as ^[OF. When I press "enter", the desired scroll is executed. Scrolling up and down is one thing, but it's particularly a pain when trying to search through the output, as it would no longer look up previous search arguments. I thought at first it's a problem with Konsole, my terminal program, or with "less" itself. But I've now tried in different terminal programs, and reading output other than output from PHP, and the ONLY time it happens is when I pipe output from PHP to "less". I have added a small test script that exhibits the problem on my system. It may work well the first time, but when repeating the same command a second time, the "weird" behavior starts. It could very well be some kind of problem with "less", but since I can only reproduce the problem with output from PHP CLI, I thought it's worth asking here. Did something about PHP CLI output change lately? This has nothing to do with PHP. The keystrokes are processed by less so your problem lies there or more likely with the terminal emulation you're using. Please try a more relevant list. -Stut -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP CLI neat errors!
Steve Finkelstein wrote: So, I use a Mac to develop with. I used to host Zend Core on my box, until I switched to the MAMP PRO framework. Unfortunately somewhere in between, this lovely issue started occuring with my CLI binary of PHP: foo:~ sf$ php -l dyld: NSLinkModule() error dyld: Symbol not found: _zend_extensions Referenced from: /usr/local/Zend/Core/lib/zend/ZendExtensionManager.so Expected in: flat namespace Did you use a new version of php? Is there an update for zend core? Maybe there's a mismatch there. -- Postgresql & php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP CLI Problem
On Feb 6, 2008 6:56 PM, Chris <[EMAIL PROTECTED]> wrote: > > > In your cronjob, replace the php5 entry with the following > > (including the backticks): > > `which php5` > > > > If that still doesn't work, replace it simply with php, not php5: > > `which php` > > You can use 'env php' instead and it'll pick up the first one in $PATH > (same sort of idea as 'which' though). > > So the job would be: > > env php -f /path/to/file.php > > Also while the curl suggestion may work, it's going to (eventually) have > timeout issues and stop working if the backup's become too large. Unless then you employ ignore_user_abort(1); et al. -- Daniel P. Brown Senior Unix Geek -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP CLI Problem
In your cronjob, replace the php5 entry with the following (including the backticks): `which php5` If that still doesn't work, replace it simply with php, not php5: `which php` You can use 'env php' instead and it'll pick up the first one in $PATH (same sort of idea as 'which' though). So the job would be: env php -f /path/to/file.php Also while the curl suggestion may work, it's going to (eventually) have timeout issues and stop working if the backup's become too large. -- Postgresql & php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP CLI Problem
On Feb 6, 2008 12:25 PM, Nathan Nobbe <[EMAIL PROTECTED]> wrote: > put the script in the webroot; then you can invoke it from cron > using curl; i imagine they have that installed. you can protect > the script with the following as the first line > if($_SERVER['REMOTE_ADDR'] !== '127.0.0.1') { die; } > > then you could hit if from cron as in > `which curl` http://localhost/backup.php > > im now waiting for what will surely be moments for another member > of the list to hack this idea to pieces ;) > but it was fun to think up! No, it's a valid idea, Nate. However, additional suggestions when going this route: 1.) Stop all public output from the script, regardless of whether or not it's only allowed by localhost. 2.) Still, move the databases and backups out of the web root. 3.) Instead of using `which curl` in the cron, use the *nix-only GET command (case sensitive). -- Daniel P. Brown Senior Unix Geek -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP CLI Problem
On Feb 6, 2008 11:48 AM, Robbert van Andel <[EMAIL PROTECTED]> wrote: > I contacted 1&1 and was told scripting was not supported. I wrote back > saying I didn't need help writing the script just how to run it. They wrote > back telling me to put it in a cron job using crontab –e and that was all > **rolls eyes**. Perhaps a call will give me the answers I need. > rob, please keep list topics on list for the benefit of others. if you dont get the answer you looking for; allow me to propose a dirty workaround. put the script in the webroot; then you can invoke it from cron using curl; i imagine they have that installed. you can protect the script with the following as the first line if($_SERVER['REMOTE_ADDR'] !== '127.0.0.1') { die; } then you could hit if from cron as in `which curl` http://localhost/backup.php im now waiting for what will surely be moments for another member of the list to hack this idea to pieces ;) but it was fun to think up! -nathan
Re: [PHP] PHP CLI Problem
On Feb 6, 2008 11:42 AM, Robbert van Andel <[EMAIL PROTECTED]> wrote: > Not an option. Which php gives me php4 and the script requires php5. > it sounds like you are using 1&1, per dans security warning earlier :) you may want to contact them and ask them how to run php5 scripts via the cli; as i know they allow usage of both 4 and 5 from the webserver, which is configurable via .htaccess directives. and, btw, if you do find out, let us know; i for one am curious how they are doing this (if at all..). -nathan
RE: [PHP] PHP CLI Problem
Not an option. Which php gives me php4 and the script requires php5. From: Nathan Nobbe [mailto:[EMAIL PROTECTED] Sent: Wednesday, February 06, 2008 8:39 AM To: Robbert van Andel Cc: Daniel Brown; php-general@lists.php.net Subject: Re: [PHP] PHP CLI Problem On Feb 6, 2008 11:33 AM, Robbert van Andel <[EMAIL PROTECTED]> wrote: I tried adding `which php5` and that didn't work. did you try running which php5 on the cli to ensure it even maps to a path ? you might need which php instead. -nathan
Re: [PHP] PHP CLI Problem
On Feb 6, 2008 11:33 AM, Robbert van Andel <[EMAIL PROTECTED]> wrote: > I tried adding `which php5` and that didn't work. did you try running which php5 on the cli to ensure it even maps to a path ? you might need which php instead. -nathan
RE: [PHP] PHP CLI Problem
D'oh. I wondered why I got that email while I was driving. Thanks for the security tip. I had actually planned on protecting those scripts after I was done getting them to work. I removed the shebang, verified the script still works from the command line but it still doesn't work with Cron. I tried adding `which php5` and that didn't work. If I run it as php, then I'm stuck using php4, so that's not really an option. Cron works on the server because I have several perl scripts running through cron with no problems. In fact, I would probably give up on this given the problems I'm having and write in perl, but the perl modules for Amazon's S3 service are poorly documented and I was not able to figure them out. There are no cron logs and the output is not sent to me after a job has completed. -Original Message- From: Daniel Brown [mailto:[EMAIL PROTECTED] Sent: Wednesday, February 06, 2008 7:52 AM To: Robbert van Andel Cc: php-general@lists.php.net Subject: Re: [PHP] PHP CLI Problem On Feb 6, 2008 1:55 AM, Robbert van Andel <[EMAIL PROTECTED]> wrote: [snip] > First off, the script runs great from the command line when I type "php5 > backup.php" but when I type ./backup.php I get an error: "bash: > ./backup.php: No such file or directory". I thought maybe this is a problem > with the top declaration in the script "#!/usr/local/bin/php5". The problem > is that it appears the server has several php5s I can reference See my note on this paragraph later in the message. And more importantly, see the addendum "SECURITY NOTICE" at the tail-end of this email. > /usr/local/apache/share/cgi-bin/php5 > /usr/local/bin/php5 > > But it doesn't matter which one I put at the top of the script, I get the > same error. In this case, use /usr/local/bin/php5, which will almost undoubtedly be compiled as a CLI object, while the ../apache/share/cgi-bin/php5 is most likely a CGI binary or (less likely) Apache module. However, keep this part in mind, as with the first paragraph, for later in the message. > Okay, so I can live with having to type "php5 backup.php". However, when I > try to make a cron job from the script, the script never runs. The crontab > entry looks like this > 1 0 * * 2 php5 > /kunden/homepages/23/d117947228/htdocs/oregonswimming/administration/backup/ > backup.php > backup.log In your cronjob, replace the php5 entry with the following (including the backticks): `which php5` If that still doesn't work, replace it simply with php, not php5: `which php` This allows BASh/Shell to execute the eval'd command typed within the backticks. > I know the backup never runs because I redirect the output to a file and > have an email sent to me upon conclusion of the script. The log file > doesn't show anything nor do I ever receive an email. My web host will not > provide any support for scripting, so I'm hoping someone here can help. Are you certain that the user under which the script is executed via cron is yourself? On rare occasions (some BSD boxes, Cobalt RaQ RHL variants, et cetera), cron will not always run as the local user. It may run as 'cron', 'crond', 'daemon', 'nobody', 'unpriv', 'anon', or as whomever the sysop has it configured. > Questions: > * How do I determine what to put at the top of the script so that I can just > call "backup.php"? Doing that is not such a great idea, and here's where the first two paragraphs come into play: remove the interpreter designation line (the first line, containing the #! characters). Make sure the script is enclosed in tags. You can find scripts that written to specifically run as crons that instead have the interpreter designator, but it's just one more thing you'll have to manually change when porting from one system to another, or if your host updates their configuration. PLUS: Keep in mind that, even when using an interpreter designator, you *still* have to enclose your code in the tags (or, if short_open_tags is on, which it probably is, just use tags). Why? Because PHP is set to parse *only* code between those tags, and even if you run the CLI with the -r flag (which allows you to run code without the tags), it will only run /one line/ of code per call. (See: `which php` --help -OR- `which php5` --help) So if you absolutely want to run it as ./backup.php from the local directory, or /kunden/homepages/23/d117947228/htdocs/oregonswimming/administration/backup/ backup.php, here are the steps to do so: 1.) chmod 755 /kunden/homepages/23/d117947228/htdocs/oregonswimming/administration/backup/ backup.php 2.) Line 1 (backup.php): #!/usr/local/bin/php5 (or whatever 'which php5' or &
Re: [PHP] PHP CLI Problem
On Feb 6, 2008 1:55 AM, Robbert van Andel <[EMAIL PROTECTED]> wrote: [snip] > First off, the script runs great from the command line when I type "php5 > backup.php" but when I type ./backup.php I get an error: "bash: > ./backup.php: No such file or directory". I thought maybe this is a problem > with the top declaration in the script "#!/usr/local/bin/php5". The problem > is that it appears the server has several php5s I can reference See my note on this paragraph later in the message. And more importantly, see the addendum "SECURITY NOTICE" at the tail-end of this email. > /usr/local/apache/share/cgi-bin/php5 > /usr/local/bin/php5 > > But it doesn't matter which one I put at the top of the script, I get the > same error. In this case, use /usr/local/bin/php5, which will almost undoubtedly be compiled as a CLI object, while the ../apache/share/cgi-bin/php5 is most likely a CGI binary or (less likely) Apache module. However, keep this part in mind, as with the first paragraph, for later in the message. > Okay, so I can live with having to type "php5 backup.php". However, when I > try to make a cron job from the script, the script never runs. The crontab > entry looks like this > 1 0 * * 2 php5 > /kunden/homepages/23/d117947228/htdocs/oregonswimming/administration/backup/ > backup.php > backup.log In your cronjob, replace the php5 entry with the following (including the backticks): `which php5` If that still doesn't work, replace it simply with php, not php5: `which php` This allows BASh/Shell to execute the eval'd command typed within the backticks. > I know the backup never runs because I redirect the output to a file and > have an email sent to me upon conclusion of the script. The log file > doesn't show anything nor do I ever receive an email. My web host will not > provide any support for scripting, so I'm hoping someone here can help. Are you certain that the user under which the script is executed via cron is yourself? On rare occasions (some BSD boxes, Cobalt RaQ RHL variants, et cetera), cron will not always run as the local user. It may run as 'cron', 'crond', 'daemon', 'nobody', 'unpriv', 'anon', or as whomever the sysop has it configured. > Questions: > * How do I determine what to put at the top of the script so that I can just > call "backup.php"? Doing that is not such a great idea, and here's where the first two paragraphs come into play: remove the interpreter designation line (the first line, containing the #! characters). Make sure the script is enclosed in tags. You can find scripts that written to specifically run as crons that instead have the interpreter designator, but it's just one more thing you'll have to manually change when porting from one system to another, or if your host updates their configuration. PLUS: Keep in mind that, even when using an interpreter designator, you *still* have to enclose your code in the tags (or, if short_open_tags is on, which it probably is, just use tags). Why? Because PHP is set to parse *only* code between those tags, and even if you run the CLI with the -r flag (which allows you to run code without the tags), it will only run /one line/ of code per call. (See: `which php` --help -OR- `which php5` --help) So if you absolutely want to run it as ./backup.php from the local directory, or /kunden/homepages/23/d117947228/htdocs/oregonswimming/administration/backup/backup.php, here are the steps to do so: 1.) chmod 755 /kunden/homepages/23/d117947228/htdocs/oregonswimming/administration/backup/backup.php 2.) Line 1 (backup.php): #!/usr/local/bin/php5 (or whatever 'which php5' or 'which php' says - no backticks here) 3.) Enclose your code in tags, not including the interpreter designator (first line). > * What, if anything, do I need to do to make the script work from cron? See above answers. SECURITY NOTICE Here are some things to consider in this specific situation: 1.) NEVER disclose full server path information as you did in your email. From that, I was easily able to discover the domain name, based upon the fact that Oregon is a US state and "swimming" would indicate the interests were most likely of a group or charitable ORGanization. ;-P 2.) It's always a Bad Idea[tm] to place crons of that nature in the web path. I was able to run the cron without the need of logging into your admin panel, because there was no security to stop me. And while all it will do is create a backup of your databases in this particular case, the output from that file also gives me *highly sensitive*, critical information about the location of web path information, and ABSOLUTE WORST - gives me full access to all of your database information in plain-text, and even a convenient zip file. ACTION ITEMS: 1.) *IMMEDIATELY* move the 'backups' directory out of the webroot. Place it somewhere like /kunden/homepages/23/d1179
Re: [PHP] PHP CLI Problem
Robbert van Andel wrote: I am having trouble with a PHP CLI script I wrote to help manage my website. The site is on a shared hosting server where the PHP installation is set up as a CGI. The script creates some backups of my databases and sends them to Amazon's S3 service. First off, the script runs great from the command line when I type "php5 backup.php" but when I type ./backup.php I get an error: "bash: ./backup.php: No such file or directory". I thought maybe this is a problem with the top declaration in the script "#!/usr/local/bin/php5". The problem is that it appears the server has several php5s I can reference /usr/local/apache/share/cgi-bin/php5 /usr/local/bin/php5 But it doesn't matter which one I put at the top of the script, I get the same error. Okay, so I can live with having to type "php5 backup.php". However, when I try to make a cron job from the script, the script never runs. The crontab entry looks like this 1 0 * * 2 php5 /kunden/homepages/23/d117947228/htdocs/oregonswimming/administration/backup/ backup.php > backup.log Are you trying to add this to your /etc/crontab file directly, or are you issuing crontab -e from the command line? If you are entering the above line into the crontab directly, then you are missing a parameter. Between the day of the week and where you have php5, you need to add the user that the script is suppose to run as. Since you are able to run the script manually, it must be something to do with how/where you are entering it into cron and/or the environment variables available to the user that your crontag launches the script as. Maybe without a complete login, the cron user doesn't have the /usr/local/bin/ in its PATH ? Just a couple thoughts. I know the backup never runs because I redirect the output to a file and have an email sent to me upon conclusion of the script. The log file doesn't show anything nor do I ever receive an email. My web host will not provide any support for scripting, so I'm hoping someone here can help. Questions: * How do I determine what to put at the top of the script so that I can just call "backup.php"? * What, if anything, do I need to do to make the script work from cron? I've seen some comments on the web regarding PHP CLI when PHP is a CGI, but none of them seem to apply to me. Thank you in advance for your help. Robbert -- Jim Lucas "Some men are born to greatness, some achieve greatness, and some have greatness thrust upon them." Twelfth Night, Act II, Scene V by William Shakespeare -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP CLI Problem
On Feb 6, 2008 9:36 AM, Robbert van Andel <[EMAIL PROTECTED]> wrote: > I guess I spoke too soon. Even though the script runs from anywhere (that > I > have access too), when I put the perl script in a cronjob, the php script > just refuses to run. There's no output, just the output from the perl > script. And yes, I did set up the perl script to print the output of the > php script. Any ideas? Is there some special consideration I have to > give > to the fact that my PHP installation is setup as a CGI? I've never had > this > much trouble getting a PHP CLI script to run. there are 2 ways to run a php cli script. the first is to prefix the name of the script with php; eg php backup.php if you are specifying this in a cron job, you will have to supply the full path to the php interpreter, which you can find via which php (sorry jocheem, i know you already said that, but my system doesnt have php5, only php [even though its 5] so i thought id mention it again) that is the way i prefer to do it but i wont elaborate as there is no point now. the second way is to make the script executable; this is a 2 step process. the first step is to prefix the contents of the file with #!/path/to/php/binary where the path is the same as earlier, found via the which command. the second step is to mark the script as executable, hopefully you are familiar enough to do that yourself, but just to test it as the user who created it, you can do simply, chmod u+x backup.php i suspect in your case the cron job doesnt know the path to the php binary, ive encountered this before; although its strange its still occurring within the perl script; however i cant help you with that ;) o, btw; here is the relevant page in the manual http://us2.php.net/manual/en/features.commandline.php -nathan
RE: [PHP] PHP CLI Problem
I guess I spoke too soon. Even though the script runs from anywhere (that I have access too), when I put the perl script in a cronjob, the php script just refuses to run. There's no output, just the output from the perl script. And yes, I did set up the perl script to print the output of the php script. Any ideas? Is there some special consideration I have to give to the fact that my PHP installation is setup as a CGI? I've never had this much trouble getting a PHP CLI script to run. Robbert -Original Message- From: Robbert van Andel [mailto:[EMAIL PROTECTED] Sent: Wednesday, February 06, 2008 6:14 AM To: php-general@lists.php.net Subject: RE: [PHP] PHP CLI Problem Thank you, that was very helpful. I created a perl script because the shell script wouldn't run either. It too gave an error stating the file or directory could not be found. The perl script runs a shell command from within it to run backup.php. Manual tests show that that works, I put it in a cron job and am confident that it will run. Robbert -Original Message- From: Chris [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 05, 2008 11:06 PM To: Robbert van Andel Cc: php-general@lists.php.net Subject: Re: [PHP] PHP CLI Problem > First off, the script runs great from the command line when I type "php5 > backup.php" but when I type ./backup.php I get an error: "bash: > ./backup.php: No such file or directory". Maybe backup.php that you think it's running is the wrong one. Add something like: echo "I am file " . __FILE__ . "\n"; in your backup.php file and see if that's printed out when you run "php5 backup.php". If it's not, then you're editing the wrong file. > I thought maybe this is a problem > with the top declaration in the script "#!/usr/local/bin/php5". If you have that as the first line, then you should just need to chmod +x the backup.php file. > The problem > is that it appears the server has several php5s I can reference > > /usr/local/apache/share/cgi-bin/php5 > /usr/local/bin/php5 Ask your host which is the right one (99% sure it'll be /usr/local/bin/php5). > Questions: > * How do I determine what to put at the top of the script so that I can just > call "backup.php"? What difference does it make whether the full path is included in the cron job or not? You need to use the full path somewhere (whether it's in the cron job or in a shell script). You could create a shell script: #!/bin/bash /usr/local/bin/php5 -f /path/to/backup.php chmod +x the new script. Call that instead in cron. > * What, if anything, do I need to do to make the script work from cron? Use the full path to php, use the full path to your backup.php file. -- Postgresql & php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] PHP CLI Problem
Thank you, that was very helpful. I created a perl script because the shell script wouldn't run either. It too gave an error stating the file or directory could not be found. The perl script runs a shell command from within it to run backup.php. Manual tests show that that works, I put it in a cron job and am confident that it will run. Robbert -Original Message- From: Chris [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 05, 2008 11:06 PM To: Robbert van Andel Cc: php-general@lists.php.net Subject: Re: [PHP] PHP CLI Problem > First off, the script runs great from the command line when I type "php5 > backup.php" but when I type ./backup.php I get an error: "bash: > ./backup.php: No such file or directory". Maybe backup.php that you think it's running is the wrong one. Add something like: echo "I am file " . __FILE__ . "\n"; in your backup.php file and see if that's printed out when you run "php5 backup.php". If it's not, then you're editing the wrong file. > I thought maybe this is a problem > with the top declaration in the script "#!/usr/local/bin/php5". If you have that as the first line, then you should just need to chmod +x the backup.php file. > The problem > is that it appears the server has several php5s I can reference > > /usr/local/apache/share/cgi-bin/php5 > /usr/local/bin/php5 Ask your host which is the right one (99% sure it'll be /usr/local/bin/php5). > Questions: > * How do I determine what to put at the top of the script so that I can just > call "backup.php"? What difference does it make whether the full path is included in the cron job or not? You need to use the full path somewhere (whether it's in the cron job or in a shell script). You could create a shell script: #!/bin/bash /usr/local/bin/php5 -f /path/to/backup.php chmod +x the new script. Call that instead in cron. > * What, if anything, do I need to do to make the script work from cron? Use the full path to php, use the full path to your backup.php file. -- Postgresql & php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP CLI Problem
Robbert van Andel schreef: I am having trouble with a PHP CLI script I wrote to help manage my website. The site is on a shared hosting server where the PHP installation is set up as a CGI. The script creates some backups of my databases and sends them to Amazon's S3 service. First off, the script runs great from the command line when I type "php5 backup.php" but when I type ./backup.php I get an error: "bash: ./backup.php: No such file or directory". is the script marked as executable? I thought maybe this is a problem with the top declaration in the script "#!/usr/local/bin/php5". The problem is that it appears the server has several php5s I can reference /usr/local/apache/share/cgi-bin/php5 /usr/local/bin/php5 to determine which php5 you are using type: $> which php5 this gives you the full path, which you will need to use in the relevant cron line (and/or the shebang line at the top of the script) - cron requires fullpaths. But it doesn't matter which one I put at the top of the script, I get the same error. Okay, so I can live with having to type "php5 backup.php". However, when I try to make a cron job from the script, the script never runs. The crontab entry looks like this 1 0 * * 2 php5 /kunden/homepages/23/d117947228/htdocs/oregonswimming/administration/backup/ backup.php > backup.log I know the backup never runs because I redirect the output to a file and have an email sent to me upon conclusion of the script. The log file doesn't show anything nor do I ever receive an email. My web host will not provide any support for scripting, so I'm hoping someone here can help. Questions: * How do I determine what to put at the top of the script so that I can just call "backup.php"? * What, if anything, do I need to do to make the script work from cron? I've seen some comments on the web regarding PHP CLI when PHP is a CGI, but none of them seem to apply to me. Thank you in advance for your help. Robbert -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP CLI Problem
First off, the script runs great from the command line when I type "php5 backup.php" but when I type ./backup.php I get an error: "bash: ./backup.php: No such file or directory". Maybe backup.php that you think it's running is the wrong one. Add something like: echo "I am file " . __FILE__ . "\n"; in your backup.php file and see if that's printed out when you run "php5 backup.php". If it's not, then you're editing the wrong file. I thought maybe this is a problem with the top declaration in the script "#!/usr/local/bin/php5". If you have that as the first line, then you should just need to chmod +x the backup.php file. The problem is that it appears the server has several php5s I can reference /usr/local/apache/share/cgi-bin/php5 /usr/local/bin/php5 Ask your host which is the right one (99% sure it'll be /usr/local/bin/php5). Questions: * How do I determine what to put at the top of the script so that I can just call "backup.php"? What difference does it make whether the full path is included in the cron job or not? You need to use the full path somewhere (whether it's in the cron job or in a shell script). You could create a shell script: #!/bin/bash /usr/local/bin/php5 -f /path/to/backup.php chmod +x the new script. Call that instead in cron. * What, if anything, do I need to do to make the script work from cron? Use the full path to php, use the full path to your backup.php file. -- Postgresql & php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php-cli vs python
On Thu, June 7, 2007 10:55 am, jose javier parra sanchez wrote: > Hi. One big diferrence is that python can be run interactively, while > php not. That's a really good advantage to debug the scripts. Anyway, > use the one you fell more comfortable. U. PHP has dozens of debuggers, and you can run CLI with -a to be interactive, or with -r to run a bit of code directly. -- Some people have a "gift" link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php-cli vs python
I use PHP extensively for command line processing. Why not just try it and see if it works well for you? On Wed, June 6, 2007 5:13 pm, Abdullah Ramazanoglu wrote: > Hello, > > I'm already (going to) use php for web based development. Shell > scripting > and compiled languages have their own places, but there's also a place > for > a high level scripting language. While people usually use python (for > higher level and perl for lower level tasks) for this, I really wonder > whether this would be worthwhile for me. > > I have just cursory info about python, and I'm by no means a php > expert. So > I can't reliably compare the two, but my rationale so far is simple: > If > php5, with its enhanced object oriented features and rich libraries is > on > par with python on the command line, then wouldn't it make better > sense > for me to use php for both web and cli/gui development? > > Nevertheless, I can't ignore the fact that people do use python almost > exclusively for high level CLI/GUI scripting. Where's the catch? > What's > the top 3 killer features of python against php (and vice versa)? > > Any ideas, pointers, analysis, insights are most welcome. This is a > rather > strategical crossroads for me, and I'd very much like to make an > informed > decision. > > Thank you and kind regards. > -- > Abdullah Ramazanoglu > aramazan ÃT myrealbox D0T cöm > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- Some people have a "gift" link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php-cli vs python
On 6/7/07, jose javier parra sanchez <[EMAIL PROTECTED]> wrote: Hi. One big diferrence is that python can be run interactively, while php not. That's a really good advantage to debug the scripts. Anyway, use the one you fell more comfortable. 2007/6/7, Abdullah Ramazanoglu <[EMAIL PROTECTED]>: > Hello, > > I'm already (going to) use php for web based development. Shell scripting > and compiled languages have their own places, but there's also a place for > a high level scripting language. While people usually use python (for > higher level and perl for lower level tasks) for this, I really wonder > whether this would be worthwhile for me. > > I have just cursory info about python, and I'm by no means a php expert. So > I can't reliably compare the two, but my rationale so far is simple: If > php5, with its enhanced object oriented features and rich libraries is on > par with python on the command line, then wouldn't it make better sense > for me to use php for both web and cli/gui development? > > Nevertheless, I can't ignore the fact that people do use python almost > exclusively for high level CLI/GUI scripting. Where's the catch? What's > the top 3 killer features of python against php (and vice versa)? > > Any ideas, pointers, analysis, insights are most welcome. This is a rather > strategical crossroads for me, and I'd very much like to make an informed > decision. > > Thank you and kind regards. > -- > Abdullah Ramazanoglu > aramazan ÄT myrealbox D0T cöm > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php My mistake I thought that's what `php -a` did. -- Daniel P. Brown [office] (570-) 587-7080 Ext. 272 [mobile] (570-) 766-8107 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php-cli vs python
Hi. One big diferrence is that python can be run interactively, while php not. That's a really good advantage to debug the scripts. Anyway, use the one you fell more comfortable. 2007/6/7, Abdullah Ramazanoglu <[EMAIL PROTECTED]>: Hello, I'm already (going to) use php for web based development. Shell scripting and compiled languages have their own places, but there's also a place for a high level scripting language. While people usually use python (for higher level and perl for lower level tasks) for this, I really wonder whether this would be worthwhile for me. I have just cursory info about python, and I'm by no means a php expert. So I can't reliably compare the two, but my rationale so far is simple: If php5, with its enhanced object oriented features and rich libraries is on par with python on the command line, then wouldn't it make better sense for me to use php for both web and cli/gui development? Nevertheless, I can't ignore the fact that people do use python almost exclusively for high level CLI/GUI scripting. Where's the catch? What's the top 3 killer features of python against php (and vice versa)? Any ideas, pointers, analysis, insights are most welcome. This is a rather strategical crossroads for me, and I'd very much like to make an informed decision. Thank you and kind regards. -- Abdullah Ramazanoglu aramazan ÄT myrealbox D0T cöm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php-cli vs python
Abdullah Ramazanoglu wrote: Hello, I'm already (going to) use php for web based development. Shell scripting and compiled languages have their own places, but there's also a place for a high level scripting language. While people usually use python (for higher level and perl for lower level tasks) for this, I really wonder whether this would be worthwhile for me. I have just cursory info about python, and I'm by no means a php expert. So I can't reliably compare the two, but my rationale so far is simple: If php5, with its enhanced object oriented features and rich libraries is on par with python on the command line, then wouldn't it make better sense for me to use php for both web and cli/gui development? Nevertheless, I can't ignore the fact that people do use python almost exclusively for high level CLI/GUI scripting. Where's the catch? What's the top 3 killer features of python against php (and vice versa)? Any ideas, pointers, analysis, insights are most welcome. This is a rather strategical crossroads for me, and I'd very much like to make an informed decision. If you want to have any sort of code re-use, then you're going to have to use php (or python) for both. Otherwise you have to start again from scratch in python code (creating more places for bugs to hide and making the whole thing more complicated). While they can access the same database, there's nothing else they can share. Personally I'd stick to one or the other for the whole project, you'll save yourself a lot of headaches in the future. -- Postgresql & php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php cli and mysql
FYI - the problem with mysql.sock has been an support issue at apple.com before. http://docs.info.apple.com/article.html?artnum=301457 /frank 15 nov 2006 kl. 11.03 skrev Roman Neuhauser: # [EMAIL PROTECTED] / 2006-11-14 18:56:01 -0500: Roman Neuhauser wrote: # [EMAIL PROTECTED] / 2006-11-14 20:17:16 +0200: On 11/14/06, James Tu <[EMAIL PROTECTED]> wrote: I'm running a php script from the command line (I'm on OS X) and I'm getting ... Warning: mysql_connect(): Can't connect to local MySQL server through socket '/var/mysql/mysql.sock' (2) touch /var/mysql/mysql.sock chmod 777 /var/mysql/mysql.sock How could that possibly help? Because if the mysql.sock file is missing the mysql server won't start. If the mysql server isn't running the PHP script won't work. So I think it helps a lot. He didn't have trouble running the mysql server (in fact the original message said the same script worked when run from apache). So even if the file was there mysql wouldn't listen on it. -- How many Vietnam vets does it take to screw in a light bulb? You don't know, man. You don't KNOW. Cause you weren't THERE. http://bash.org/?255991 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php cli and mysql
# [EMAIL PROTECTED] / 2006-11-14 18:56:01 -0500: > Roman Neuhauser wrote: > ># [EMAIL PROTECTED] / 2006-11-14 20:17:16 +0200: > > > >>On 11/14/06, James Tu <[EMAIL PROTECTED]> wrote: > >> > >>>I'm running a php script from the command line (I'm on OS X) and I'm > >>>getting ... > >>> > >>>Warning: mysql_connect(): Can't connect to local MySQL server through > >>>socket '/var/mysql/mysql.sock' (2) > >>> > >>touch /var/mysql/mysql.sock > >>chmod 777 /var/mysql/mysql.sock > > > >How could that possibly help? > > > Because if the mysql.sock file is missing the mysql server won't start. > If the mysql server isn't running the PHP script won't work. So I think > it helps a lot. He didn't have trouble running the mysql server (in fact the original message said the same script worked when run from apache). So even if the file was there mysql wouldn't listen on it. -- How many Vietnam vets does it take to screw in a light bulb? You don't know, man. You don't KNOW. Cause you weren't THERE. http://bash.org/?255991 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php cli and mysql
Tom Ray [Lists] wrote: Chris wrote: Tom Ray [Lists] wrote: Roman Neuhauser wrote: # [EMAIL PROTECTED] / 2006-11-14 20:17:16 +0200: On 11/14/06, James Tu <[EMAIL PROTECTED]> wrote: I'm running a php script from the command line (I'm on OS X) and I'm getting ... Warning: mysql_connect(): Can't connect to local MySQL server through socket '/var/mysql/mysql.sock' (2) touch /var/mysql/mysql.sock chmod 777 /var/mysql/mysql.sock How could that possibly help? Because if the mysql.sock file is missing the mysql server won't start. If the mysql server isn't running the PHP script won't work. So I think it helps a lot. Actually the opposite - it becomes a lot harder to debug/diagnose. PHP uses the socket file to talk to mysql if you connect to 'localhost' rather than using a tcp/ip connection. If the socket file is invalid (as this would be), then mysql_connect fails, mysql_query fails and so on. The problem as it turns out was that php was looking in the wrong place, if this file was there and empty, then you'd get completely different errors which would make it harder to find the original problem. Well that's odd because on all my servers the mysql.sock is empty and if it's missing mysql tells me it can't find the sock file when it starts up. This wasn't an actual PHP problem, even trying to connect to the mysql server via /usr/local/mysql/bin/mysql -u user -p database would have produced that error. It was a php problem. PHP was looking for the socket file in the wrong location. To quote: "I found it at /tmp/mysql.sock Why is the CLI looking for it at /var/myslq/mysql.sock?" Randomly creating socket files in the location php is looking for doesn't solve this. -- Postgresql & php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php cli and mysql
Chris wrote: Tom Ray [Lists] wrote: Roman Neuhauser wrote: # [EMAIL PROTECTED] / 2006-11-14 20:17:16 +0200: On 11/14/06, James Tu <[EMAIL PROTECTED]> wrote: I'm running a php script from the command line (I'm on OS X) and I'm getting ... Warning: mysql_connect(): Can't connect to local MySQL server through socket '/var/mysql/mysql.sock' (2) touch /var/mysql/mysql.sock chmod 777 /var/mysql/mysql.sock How could that possibly help? Because if the mysql.sock file is missing the mysql server won't start. If the mysql server isn't running the PHP script won't work. So I think it helps a lot. Actually the opposite - it becomes a lot harder to debug/diagnose. PHP uses the socket file to talk to mysql if you connect to 'localhost' rather than using a tcp/ip connection. If the socket file is invalid (as this would be), then mysql_connect fails, mysql_query fails and so on. The problem as it turns out was that php was looking in the wrong place, if this file was there and empty, then you'd get completely different errors which would make it harder to find the original problem. Well that's odd because on all my servers the mysql.sock is empty and if it's missing mysql tells me it can't find the sock file when it starts up. This wasn't an actual PHP problem, even trying to connect to the mysql server via /usr/local/mysql/bin/mysql -u user -p database would have produced that error. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php cli and mysql
Tom Ray [Lists] wrote: Roman Neuhauser wrote: # [EMAIL PROTECTED] / 2006-11-14 20:17:16 +0200: On 11/14/06, James Tu <[EMAIL PROTECTED]> wrote: I'm running a php script from the command line (I'm on OS X) and I'm getting ... Warning: mysql_connect(): Can't connect to local MySQL server through socket '/var/mysql/mysql.sock' (2) touch /var/mysql/mysql.sock chmod 777 /var/mysql/mysql.sock How could that possibly help? Because if the mysql.sock file is missing the mysql server won't start. If the mysql server isn't running the PHP script won't work. So I think it helps a lot. Actually the opposite - it becomes a lot harder to debug/diagnose. PHP uses the socket file to talk to mysql if you connect to 'localhost' rather than using a tcp/ip connection. If the socket file is invalid (as this would be), then mysql_connect fails, mysql_query fails and so on. The problem as it turns out was that php was looking in the wrong place, if this file was there and empty, then you'd get completely different errors which would make it harder to find the original problem. -- Postgresql & php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php cli and mysql
Roman Neuhauser wrote: # [EMAIL PROTECTED] / 2006-11-14 20:17:16 +0200: On 11/14/06, James Tu <[EMAIL PROTECTED]> wrote: I'm running a php script from the command line (I'm on OS X) and I'm getting ... Warning: mysql_connect(): Can't connect to local MySQL server through socket '/var/mysql/mysql.sock' (2) touch /var/mysql/mysql.sock chmod 777 /var/mysql/mysql.sock How could that possibly help? Because if the mysql.sock file is missing the mysql server won't start. If the mysql server isn't running the PHP script won't work. So I think it helps a lot. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php cli and mysql
# [EMAIL PROTECTED] / 2006-11-14 20:17:16 +0200: > On 11/14/06, James Tu <[EMAIL PROTECTED]> wrote: > >I'm running a php script from the command line (I'm on OS X) and I'm > >getting ... > > > >Warning: mysql_connect(): Can't connect to local MySQL server through > >socket '/var/mysql/mysql.sock' (2) > > touch /var/mysql/mysql.sock > chmod 777 /var/mysql/mysql.sock How could that possibly help? -- How many Vietnam vets does it take to screw in a light bulb? You don't know, man. You don't KNOW. Cause you weren't THERE. http://bash.org/?255991 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php cli and mysql
Thanks everyone! On Nov 14, 2006, at 3:20 PM, [EMAIL PROTECTED] wrote: You could make a new php.ini for flexibility like Jochem stated. To make things easy, just copy the file over: cp /usr/local/php5/lib/php.ini /etc/php.ini And that should do it. James Tu wrote: Please see below On Nov 14, 2006, at 2:24 PM, [EMAIL PROTECTED] wrote: Run this command: /path/to/cli/php -i|grep MYSQL_SOCKET MYSQL_SOCKET => /var/mysql/mysql.sock What does that show? It sounds like the PHP module for Apache is using a different php.ini file then the CLI version. I know for a fact that Apache is using: /usr/local/php5/lib/php.ini It also looks like the CLI versions php.ini is not pointing to the proper path to the mysql.sock. Look under the mysql section of your php.ini and fix that up. To see where its pointing, do this: /path/to/cli/php -i|grep php.ini Configuration File (php.ini) Path => /etc but when I looked inside /etc there was no php.ini, but there is a php.ini.default... I could create another here... or should I create a symbolic link to the php.ini that Apache is using? That'll tell you where the php.ini file is for the CLI version. Enjoy. James Tu wrote: ok. so the location of mysql.sock is a problem. I found it at /tmp/mysql.sock Why is the CLI looking for it at /var/myslq/mysql.sock? Now the question is... Do I change the mysql settings so that mysql.sock is at /tmp/mysql.sock? (If I do, will the PHP module with Apache still be ok?) or Do I change where the CLI is looking for mysql.sock? -James On Nov 14, 2006, at 1:17 PM, cajbecu wrote: touch /var/mysql/mysql.sock chmod 777 /var/mysql/mysql.sock On 11/14/06, James Tu <[EMAIL PROTECTED]> wrote: I'm running a php script from the command line (I'm on OS X) and I'm getting ... Warning: mysql_connect(): Can't connect to local MySQL server through socket '/var/mysql/mysql.sock' (2) Here's the script (this just tests a connection and a query...the actual script imports data from text files): #!/usr/bin/php I tested the script from a browser and the connection and query worked. Do I have to do something special in order for PHP CLI to connect to MySQL? -James --PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php --PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php --PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php --PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php --PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php cli and mysql
You could make a new php.ini for flexibility like Jochem stated. To make things easy, just copy the file over: cp /usr/local/php5/lib/php.ini /etc/php.ini And that should do it. James Tu wrote: > Please see below > > On Nov 14, 2006, at 2:24 PM, [EMAIL PROTECTED] wrote: > >> Run this command: >> >> /path/to/cli/php -i|grep MYSQL_SOCKET >> > > MYSQL_SOCKET => /var/mysql/mysql.sock > >> What does that show? It sounds like the PHP module for Apache is using >> a different php.ini file then the CLI version. >> > > I know for a fact that Apache is using: > /usr/local/php5/lib/php.ini > >> It also looks like the CLI versions php.ini is not pointing to the >> proper path to the mysql.sock. Look under the mysql section of your >> php.ini and fix that up. To see where its pointing, do this: >> >> /path/to/cli/php -i|grep php.ini >> > > Configuration File (php.ini) Path => /etc > > but when I looked inside /etc there was no php.ini, but there is a > php.ini.default... > I could create another here... > > or should I create a symbolic link to the php.ini that Apache is using? > > >> That'll tell you where the php.ini file is for the CLI version. >> >> Enjoy. >> >> >> >> James Tu wrote: >>> ok. so the location of mysql.sock is a problem. >>> I found it at /tmp/mysql.sock >>> >>> Why is the CLI looking for it at /var/myslq/mysql.sock? >>> >>> Now the question is... >>> Do I change the mysql settings so that mysql.sock is at >>> /tmp/mysql.sock? (If I do, will the PHP module with Apache still be >>> ok?) >>> or >>> Do I change where the CLI is looking for mysql.sock? >>> >>> -James >>> >>> On Nov 14, 2006, at 1:17 PM, cajbecu wrote: >>> touch /var/mysql/mysql.sock chmod 777 /var/mysql/mysql.sock On 11/14/06, James Tu <[EMAIL PROTECTED]> wrote: > I'm running a php script from the command line (I'm on OS X) and I'm > getting ... > > Warning: mysql_connect(): Can't connect to local MySQL server through > socket '/var/mysql/mysql.sock' (2) > > Here's the script (this just tests a connection and a query...the > actual script imports data from text files): > > > #!/usr/bin/php > > echo "HELLO WORLD\n"; > $connection = mysql_connect(HOST, ID, PW); > mysql_select_db(DB, $connection); > $result = mysql_query("SELECT COUNT(*) as num_of_countries from > geo_entities"); > $row = mysql_fetch_array($result); > print_r($row); > > ?> > > > I tested the script from a browser and the connection and query > worked. > Do I have to do something special in order for PHP CLI to connect to > MySQL? > > -James > > --PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > --PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php >>> >>> --PHP General Mailing List (http://www.php.net/) >>> To unsubscribe, visit: http://www.php.net/unsub.php >>> >>> >> >> --PHP General Mailing List (http://www.php.net/) >> To unsubscribe, visit: http://www.php.net/unsub.php >> >> > > --PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php cli and mysql
James Tu wrote: > Please see below > .. you fell foul of the 'there is no php.ini' trap :-) (please repeat in a homer simpson voice) > > or should I create a symbolic link to the php.ini that Apache is using? use a seperate php.ini - more flexibility > > >> That'll tell you where the php.ini file is for the CLI version. >> >> Enjoy. >> >> >> >> James Tu wrote: >>> ok. so the location of mysql.sock is a problem. >>> I found it at /tmp/mysql.sock >>> >>> Why is the CLI looking for it at /var/myslq/mysql.sock? >>> >>> Now the question is... >>> Do I change the mysql settings so that mysql.sock is at >>> /tmp/mysql.sock? (If I do, will the PHP module with Apache still be >>> ok?) >>> or >>> Do I change where the CLI is looking for mysql.sock? pointing the CLI at the actual .sock seems least invasive, no? rgds, -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php cli and mysql
Please see below On Nov 14, 2006, at 2:24 PM, [EMAIL PROTECTED] wrote: Run this command: /path/to/cli/php -i|grep MYSQL_SOCKET MYSQL_SOCKET => /var/mysql/mysql.sock What does that show? It sounds like the PHP module for Apache is using a different php.ini file then the CLI version. I know for a fact that Apache is using: /usr/local/php5/lib/php.ini It also looks like the CLI versions php.ini is not pointing to the proper path to the mysql.sock. Look under the mysql section of your php.ini and fix that up. To see where its pointing, do this: /path/to/cli/php -i|grep php.ini Configuration File (php.ini) Path => /etc but when I looked inside /etc there was no php.ini, but there is a php.ini.default... I could create another here... or should I create a symbolic link to the php.ini that Apache is using? That'll tell you where the php.ini file is for the CLI version. Enjoy. James Tu wrote: ok. so the location of mysql.sock is a problem. I found it at /tmp/mysql.sock Why is the CLI looking for it at /var/myslq/mysql.sock? Now the question is... Do I change the mysql settings so that mysql.sock is at /tmp/mysql.sock? (If I do, will the PHP module with Apache still be ok?) or Do I change where the CLI is looking for mysql.sock? -James On Nov 14, 2006, at 1:17 PM, cajbecu wrote: touch /var/mysql/mysql.sock chmod 777 /var/mysql/mysql.sock On 11/14/06, James Tu <[EMAIL PROTECTED]> wrote: I'm running a php script from the command line (I'm on OS X) and I'm getting ... Warning: mysql_connect(): Can't connect to local MySQL server through socket '/var/mysql/mysql.sock' (2) Here's the script (this just tests a connection and a query...the actual script imports data from text files): #!/usr/bin/php I tested the script from a browser and the connection and query worked. Do I have to do something special in order for PHP CLI to connect to MySQL? -James -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php --PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php --PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php cli and mysql
Run this command: /path/to/cli/php -i|grep MYSQL_SOCKET What does that show? It sounds like the PHP module for Apache is using a different php.ini file then the CLI version. It also looks like the CLI versions php.ini is not pointing to the proper path to the mysql.sock. Look under the mysql section of your php.ini and fix that up. To see where its pointing, do this: /path/to/cli/php -i|grep php.ini That'll tell you where the php.ini file is for the CLI version. Enjoy. James Tu wrote: > ok. so the location of mysql.sock is a problem. > I found it at /tmp/mysql.sock > > Why is the CLI looking for it at /var/myslq/mysql.sock? > > Now the question is... > Do I change the mysql settings so that mysql.sock is at > /tmp/mysql.sock? (If I do, will the PHP module with Apache still be ok?) > or > Do I change where the CLI is looking for mysql.sock? > > -James > > On Nov 14, 2006, at 1:17 PM, cajbecu wrote: > >> touch /var/mysql/mysql.sock >> chmod 777 /var/mysql/mysql.sock >> >> On 11/14/06, James Tu <[EMAIL PROTECTED]> wrote: >>> I'm running a php script from the command line (I'm on OS X) and I'm >>> getting ... >>> >>> Warning: mysql_connect(): Can't connect to local MySQL server through >>> socket '/var/mysql/mysql.sock' (2) >>> >>> Here's the script (this just tests a connection and a query...the >>> actual script imports data from text files): >>> >>> >>> #!/usr/bin/php >>> >> >>> echo "HELLO WORLD\n"; >>> $connection = mysql_connect(HOST, ID, PW); >>> mysql_select_db(DB, $connection); >>> $result = mysql_query("SELECT COUNT(*) as num_of_countries from >>> geo_entities"); >>> $row = mysql_fetch_array($result); >>> print_r($row); >>> >>> ?> >>> >>> >>> I tested the script from a browser and the connection and query worked. >>> Do I have to do something special in order for PHP CLI to connect to >>> MySQL? >>> >>> -James >>> >>> -- >>> PHP General Mailing List (http://www.php.net/) >>> To unsubscribe, visit: http://www.php.net/unsub.php >>> >>> >> >> --PHP General Mailing List (http://www.php.net/) >> To unsubscribe, visit: http://www.php.net/unsub.php >> >> > > --PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php cli and mysql
ok. so the location of mysql.sock is a problem. I found it at /tmp/mysql.sock Why is the CLI looking for it at /var/myslq/mysql.sock? Now the question is... Do I change the mysql settings so that mysql.sock is at /tmp/ mysql.sock? (If I do, will the PHP module with Apache still be ok?) or Do I change where the CLI is looking for mysql.sock? -James On Nov 14, 2006, at 1:17 PM, cajbecu wrote: touch /var/mysql/mysql.sock chmod 777 /var/mysql/mysql.sock On 11/14/06, James Tu <[EMAIL PROTECTED]> wrote: I'm running a php script from the command line (I'm on OS X) and I'm getting ... Warning: mysql_connect(): Can't connect to local MySQL server through socket '/var/mysql/mysql.sock' (2) Here's the script (this just tests a connection and a query...the actual script imports data from text files): #!/usr/bin/php I tested the script from a browser and the connection and query worked. Do I have to do something special in order for PHP CLI to connect to MySQL? -James -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php cli and mysql
touch /var/mysql/mysql.sock chmod 777 /var/mysql/mysql.sock On 11/14/06, James Tu <[EMAIL PROTECTED]> wrote: I'm running a php script from the command line (I'm on OS X) and I'm getting ... Warning: mysql_connect(): Can't connect to local MySQL server through socket '/var/mysql/mysql.sock' (2) Here's the script (this just tests a connection and a query...the actual script imports data from text files): #!/usr/bin/php I tested the script from a browser and the connection and query worked. Do I have to do something special in order for PHP CLI to connect to MySQL? -James -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php-cli and daemon
On Sat, May 13, 2006 5:40 pm, Michelle Konzack wrote: > I run a webserver which is a frontend for a huge PostgreSQL database. > Now I like to code some stand-alone Apps, which can connect to a > daemon uploading files and geting infos from the database > > (NO, the have no right to connect directly to the database) > > Questions for now: > > 1) How to code a daemon? http://php.net/sockets > 2) How to use ssl-certs for the connection? > The $USER must use an USB-Key with its one cert. Ya got me there... You may want to look into http://gtk.php.net for coding the GUI part of the stand-alone client application. And that MIGHT have some built-in SSL stuff to make this crystal-clear and dead easy... I'm a bit confused between the deamon, the uploading files, and the read-only access to the database, personally... That said, the PostgreSQL documentation probably has pretty clear description of how to do an SSL connection if it can be done, and workarounds if it can't: http://postgresql.org/ You might also consider tunneling all the data, uploads and PostgreSQL through SSH as a sort of Poor Man's VPN deal... -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php-cli and daemon
On 5/14/06, Michelle Konzack <[EMAIL PROTECTED]> wrote: Hello, I run a webserver which is a frontend for a huge PostgreSQL database. Now I like to code some stand-alone Apps, which can connect to a daemon uploading files and geting infos from the database (NO, the have no right to connect directly to the database) Questions for now: 1) How to code a daemon? This would be a good place to start. http://www.php.net/pcntl Depending on your app you might need to look at shared memory, but the main area to check out would be the process functions. http://www.php.net/manual/en/ref.sem.php 2) How to use ssl-certs for the connection? The $USER must use an USB-Key with its one cert. There are ssl functions you can use: http://www.php.net/manual/en/ref.openssl.php -- Postgresql & php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP CLI not present
On Wed, April 19, 2006 3:01 pm, Jeff wrote: > I'm running PHP Ver 4.4.1 on a redhat ES3 system. It appears that the > CLI is not running or not present. I thought it was installed by > default in versions >= 4.3.x. > > If I run /usr/local/bin/php -v at the command line I get nothing. > > How do I get the PHP CLI working? I don't remember at which version CLI became installed by default with Apache, but if you still have your config.nice script you'd want to check that, and the config.log and config.debug to see what happened. It's possible you just installed it in some different directory... Something like: locate php | grep bin might be useful for finding that. You could also download the source and install just the CLI pretty quickly and easily. Or you may want to upgrade anyway :-) -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] PHP CLI not present [SOLVED]
> -Original Message- > From: Jeff [mailto:[EMAIL PROTECTED] > Sent: Wednesday, April 19, 2006 16:02 > To: php-general@lists.php.net > Subject: [PHP] PHP CLI not present > > > Hey all, > > I'm running PHP Ver 4.4.1 on a redhat ES3 system. It appears > that the CLI is not running or not present. I thought it was > installed by default in versions >= 4.3.x. > > If I run /usr/local/bin/php -v at the command line I get nothing. > > How do I get the PHP CLI working? > > Thanks, > > Jeff Nevermind. Found it! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] PHP CLI - possible for mass mailing?
> -Original Message- > From: Denis Gerasimov [mailto:[EMAIL PROTECTED] > Sent: Tuesday, September 27, 2005 1:45 AM > To: PHP General Mailing List > Subject: [PHP] PHP CLI - possible for mass mailing? > > > Hello List, > > > > We are working on a PHP project that implements mass mailing > to a large > number of its subscribers (expected 100,000-200,000 users; > not spam mailing > BTW). So I am wondering if it is possible to use PHP CLI > binary for this > purpose and if there are any problems with PHP in this case. > > > > I was said that using Perl script is more suitable for such > task since PHP > scripts have problems with sending large amount of mail. > > Is that true or not? Any success/failure stories? While I don't handle nearly that volume, I routenely use the CLI binary to mail a weekly newsletter to ~200 subscribers. I have never had any problem with it. JM -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP CLI - possible for mass mailing?
Denis Gerasimov wrote: > We are working on a PHP project that implements mass mailing to a large > number of its subscribers (expected 100,000-200,000 users; not spam mailing > BTW). So I am wondering if it is possible to use PHP CLI binary for this > purpose and if there are any problems with PHP in this case. No problems that I can think of as long as you use a custom php.ini file to avoid such things as safe_mode, max_execution_time, and various other nasties that you might bump into if you run it on various servers. > I was said that using Perl script is more suitable for such task since PHP > scripts have problems with sending large amount of mail. Bah humbug. PHP CLI works just fine, and, it is quite easy to do both ncurses and text positioning/coloring for both Windows and Linux, and it is a lot easier to run it either from the web or shell. It's not the PHP script that has the problem, in reality, it's just an issue of making sure that you're sending the mails in batches, which you can do if you make sure that there's no maximum execution time set for the PHP script. > Is that true or not? Any success/failure stories? It is false. And, I am sure that someone can dig up a success story, but, I know for a fact that I'd rather use PHP for sending large amounts of email, especially if there's to be MIME parts and or HTML included in it. There are already several well-coded PEAR packages that do this for you out of the box. Warm Regards, Torgny -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php cli script with if-then's very slow
On Thu, August 18, 2005 2:14 am, Frans Fierens wrote: > I've noticed that php cli scripts using for-loops with some > if...then's > are very slow using the php cli (command line interface). The > following > php script takes somewhat 100 seconds (php v5.0.3 on a redhat linux, 3 > Ghz PC). The same program in c (see below) less than 1 second ... I > know > that php is a scripting language, but isn't the difference between de > c > compiled prog and de php script not very extreme ? In the unlikely event that you ever need code like that in a real-life application, write that part of your code in C as a Module for Apache/PHP. A cache like the Zend cache would maybe help a LITTLE as it will parse it all to byte-code only once. Though I suspect it won't help that much, as it will still have run through that byte-code over and over. Do feel free to write all your web server application in C if performance is your primary consideration. :-) -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php-cli stopping on exit.
It works fine here. Do you have any additional extensions enabled in php.ini? Edin - Original Message - From: "Simon Fredriksson" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Tuesday, August 26, 2003 7:24 AM Subject: [PHP] php-cli stopping on exit. Can someone explain why PHP freezes when I don't specify a file for it? Like when I run "php -v" it outputs: PHP 4.3.3 (cli) (built: Aug 24 2003 22:05:23) Copyright (c) 1997-2003 The PHP Group Zend Engine v1.3.0, Copyright (c) 1998-2003 Zend Technologies Then stops. It doesn't return to the commandprompt. System: WinXP Pro. //Simon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] php-cli - Controlling external programs
[snip] Bah, not the answer I was looking for...I really wanted to use PHP and I have most of what I wanted accomplished. Thanks for the tip, I will investigate. [/snip] http://us3.php.net/features.commandline If you use -a for your command line script the script will run interactively example: php -a myscript.php or if you want to use a bash line at the head of your script #!/usr/local/bin/php -a (dependent upon the location of php) HTH -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php-cli - Controlling external programs
Hi, Thursday, July 31, 2003, 1:53:50 PM, you wrote: MM> I'm writing a script to be run from the command line. It controls my DAT MM> autoloader (tape changer) and runs tar so that I can automate my backups. MM> With the -M option, tar will prompt for a new tape when the current tape is MM> full. How can I get the signal from tar that the tape needs to be changed? MM> Is there another way to interact with external programs other than, exec, MM> backticks, etc.? I'm running 4.3.2-cli on FreeBSD with POSIX and pcntl MM> functions enabled. MM> Thanks, MM> Mike Maybe this will help http://sourceforge.net/projects/mtx/ -- regards, Tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php-cli - Controlling external programs
Bah, not the answer I was looking for...I really wanted to use PHP and I have most of what I wanted accomplished. Thanks for the tip, I will investigate. "Chris Shiflett" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > --- Mike Maltese <[EMAIL PROTECTED]> wrote: > > I'm writing a script to be run from the command line. > ... > > How can I get the signal from tar that the tape needs to be changed? > > It sounds like you are wanting to write an interactive shell script. If this is > the case (e.g., I didn't misunderstand), you should probably use expect instead > of PHP. > > Hope that helps. > > Chris > > = > Become a better Web developer with the HTTP Developer's Handbook > http://httphandbook.org/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php-cli - Controlling external programs
--- Mike Maltese <[EMAIL PROTECTED]> wrote: > I'm writing a script to be run from the command line. ... > How can I get the signal from tar that the tape needs to be changed? It sounds like you are wanting to write an interactive shell script. If this is the case (e.g., I didn't misunderstand), you should probably use expect instead of PHP. Hope that helps. Chris = Become a better Web developer with the HTTP Developer's Handbook http://httphandbook.org/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP cli on Mac OSX
* Thus wrote René Fournier ([EMAIL PROTECTED]): > Hello, > > I installed Entropy package of PHP on my 10.2.6 OSX > (http://www2.entropy.ch/download/Entropy-PHP-4.3.2-5.dmg), which states > that it includes PHP command line. But when I go to Terminal and type > "PHP somescript.php4", it returns "Command not found". > > What am I missing? try: php somscript.php4 your terminal shell is case sensitive. If that doesn't work do an 'echo $PATH' and make sure your php binary is in one of those directories. I love OSX even though I don't use it :) Curt -- "I used to think I was indecisive, but now I'm not so sure." -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP CLI question
ok, so there are plenty of ways to work around it ;-) I guess my original question should be answered as such? "No, you cannot specify a different configuration file name other than php.ini, you must either hack the C code or supply a workaround at runtime." Monte On Thu, 2003-06-05 at 15:07, Mark wrote: > Wrap it in a shell script or batch file. > > Something like: > > REM ---Start cli.bat--- > ./cli/php.exe -c <> %1 %2 %3 %4 %5 %6 %7 %8 %9 > @exit > REM ---End cli.bat--- > > > --- Monte Ohrt <[EMAIL PROTECTED]> wrote: > > Hi Adam, > > > > I know it can be altered with a command-line switch, but it is the > > default that I want to change. I don't want to have to remember to > > set > > the -c flag everytime, or go back and change all my existing > > scripts. > > > > Monte > > > > On Thu, 2003-06-05 at 09:53, Adam Voigt wrote: > > > >From a ./php -h: > > > > > > -c | Look for php.ini file in this directory > > > > > > The "|" means "OR", so logic would dictate you can point > > > directly to the file with the -c option. > > > > > > > > > On Thu, 2003-06-05 at 10:35, Monte Ohrt wrote: > > > > Hi Cal, > > > > > > > > I may be missing something, but I don't see how this page > > answers either > > > > of my questions. ini_set() is for setting configuration > > options. > > > > > > > > Monte > > > > > > > > On Thu, 2003-06-05 at 09:23, Cal Evans wrote: > > > > > http://www.php.net/manual/en/function.ini-set.php > > > > > > > > > > * Cal Evans > > > > > * http://www.christianperformer.com > > > > > * Stay plugged into your audience > > > > > * The measure of a programmer is not the number of lines of > > code he writes > > > > > but the number of lines he does not have to write. > > > > > * > > > > > > > > > > - Original Message - > > > > > From: "Monte Ohrt" <[EMAIL PROTECTED]> > > > > > To: <[EMAIL PROTECTED]> > > > > > Cc: <[EMAIL PROTECTED]> > > > > > Sent: Thursday, June 05, 2003 9:22 AM > > > > > Subject: [PHP] PHP CLI question > > > > > > > > > > > > > > > > Hi, > > > > > > > > > > > > A couple of questions: > > > > > > > > > > > > 1) Is there a way to make the CLI version of PHP ignore > > certain settings > > > > > > in the php.ini file? For instance, I don't want the ioncube > > accelerator > > > > > > invoked when using PHP from the command line. My current > > work around is > > > > > > to use two separate init files, php.ini and php-cli.ini ... > > and this > > > > > > brings me to my second question: > > > > > > > > > > > > 2) Is there a way to specify a different name for the > > php.ini file, > > > > > > apart from hacking php_ini.c ? It seems I can only change > > the _path_ to > > > > > > the file, but not the filename itself. > > > > > > > > > > > > TIA > > > > > > Monte > > > > > > > > > > > > > > > > > > > > > > > > -- > > > > > > PHP General Mailing List (http://www.php.net/) > > > > > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > > > > > > > > > > -- > > Monte Ohrt <[EMAIL PROTECTED]> > > > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > = > Mark Weinstock > [EMAIL PROTECTED] > *** > You can't demand something as a "right" unless you are willing to fight to death to > defend everyone else's right to the same thing. > *** > > __ > Do you Yahoo!? > Yahoo! Calendar - Free online calendar with sync to Outlook(TM). > http://calendar.yahoo.com -- Monte Ohrt <[EMAIL PROTECTED]> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP CLI question
Wrap it in a shell script or batch file. Something like: REM ---Start cli.bat--- ./cli/php.exe -c <> %1 %2 %3 %4 %5 %6 %7 %8 %9 @exit REM ---End cli.bat--- --- Monte Ohrt <[EMAIL PROTECTED]> wrote: > Hi Adam, > > I know it can be altered with a command-line switch, but it is the > default that I want to change. I don't want to have to remember to > set > the -c flag everytime, or go back and change all my existing > scripts. > > Monte > > On Thu, 2003-06-05 at 09:53, Adam Voigt wrote: > > >From a ./php -h: > > > > -c | Look for php.ini file in this directory > > > > The "|" means "OR", so logic would dictate you can point > > directly to the file with the -c option. > > > > > > On Thu, 2003-06-05 at 10:35, Monte Ohrt wrote: > > > Hi Cal, > > > > > > I may be missing something, but I don't see how this page > answers either > > > of my questions. ini_set() is for setting configuration > options. > > > > > > Monte > > > > > > On Thu, 2003-06-05 at 09:23, Cal Evans wrote: > > > > http://www.php.net/manual/en/function.ini-set.php > > > > > > > > * Cal Evans > > > > * http://www.christianperformer.com > > > > * Stay plugged into your audience > > > > * The measure of a programmer is not the number of lines of > code he writes > > > > but the number of lines he does not have to write. > > > > * > > > > > > > > - Original Message - > > > > From: "Monte Ohrt" <[EMAIL PROTECTED]> > > > > To: <[EMAIL PROTECTED]> > > > > Cc: <[EMAIL PROTECTED]> > > > > Sent: Thursday, June 05, 2003 9:22 AM > > > > Subject: [PHP] PHP CLI question > > > > > > > > > > > > > Hi, > > > > > > > > > > A couple of questions: > > > > > > > > > > 1) Is there a way to make the CLI version of PHP ignore > certain settings > > > > > in the php.ini file? For instance, I don't want the ioncube > accelerator > > > > > invoked when using PHP from the command line. My current > work around is > > > > > to use two separate init files, php.ini and php-cli.ini ... > and this > > > > > brings me to my second question: > > > > > > > > > > 2) Is there a way to specify a different name for the > php.ini file, > > > > > apart from hacking php_ini.c ? It seems I can only change > the _path_ to > > > > > the file, but not the filename itself. > > > > > > > > > > TIA > > > > > Monte > > > > > > > > > > > > > > > > > > > > -- > > > > > PHP General Mailing List (http://www.php.net/) > > > > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > > > > > > > -- > Monte Ohrt <[EMAIL PROTECTED]> > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > = Mark Weinstock [EMAIL PROTECTED] *** You can't demand something as a "right" unless you are willing to fight to death to defend everyone else's right to the same thing. *** __ Do you Yahoo!? Yahoo! Calendar - Free online calendar with sync to Outlook(TM). http://calendar.yahoo.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP CLI question
On Friday 06 June 2003 01:43, Monte Ohrt wrote: > I know it can be altered with a command-line switch, but it is the > default that I want to change. I don't want to have to remember to set > the -c flag everytime, or go back and change all my existing scripts. You can run separate ./configure commands for the apache (or whatever) module and for the CLI version, specifying a different "--with-config-file-path". -- Jason Wong -> Gremlins Associates -> www.gremlins.biz Open Source Software Systems Integrators * Web Design & Hosting * Internet & Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general -- /* Cold, adj.: When the politicians walk around with their hands in their own pockets. */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP CLI question
Hi Adam, I know it can be altered with a command-line switch, but it is the default that I want to change. I don't want to have to remember to set the -c flag everytime, or go back and change all my existing scripts. Monte On Thu, 2003-06-05 at 09:53, Adam Voigt wrote: > >From a ./php -h: > > -c | Look for php.ini file in this directory > > The "|" means "OR", so logic would dictate you can point > directly to the file with the -c option. > > > On Thu, 2003-06-05 at 10:35, Monte Ohrt wrote: > > Hi Cal, > > > > I may be missing something, but I don't see how this page answers either > > of my questions. ini_set() is for setting configuration options. > > > > Monte > > > > On Thu, 2003-06-05 at 09:23, Cal Evans wrote: > > > http://www.php.net/manual/en/function.ini-set.php > > > > > > * Cal Evans > > > * http://www.christianperformer.com > > > * Stay plugged into your audience > > > * The measure of a programmer is not the number of lines of code he writes > > > but the number of lines he does not have to write. > > > * > > > > > > - Original Message - > > > From: "Monte Ohrt" <[EMAIL PROTECTED]> > > > To: <[EMAIL PROTECTED]> > > > Cc: <[EMAIL PROTECTED]> > > > Sent: Thursday, June 05, 2003 9:22 AM > > > Subject: [PHP] PHP CLI question > > > > > > > > > > Hi, > > > > > > > > A couple of questions: > > > > > > > > 1) Is there a way to make the CLI version of PHP ignore certain settings > > > > in the php.ini file? For instance, I don't want the ioncube accelerator > > > > invoked when using PHP from the command line. My current work around is > > > > to use two separate init files, php.ini and php-cli.ini ... and this > > > > brings me to my second question: > > > > > > > > 2) Is there a way to specify a different name for the php.ini file, > > > > apart from hacking php_ini.c ? It seems I can only change the _path_ to > > > > the file, but not the filename itself. > > > > > > > > TIA > > > > Monte > > > > > > > > > > > > > > > > -- > > > > PHP General Mailing List (http://www.php.net/) > > > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > > > > -- Monte Ohrt <[EMAIL PROTECTED]> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP CLI question
Or as Jason noted at compile time. Monte Ohrt wrote: ok, so there are plenty of ways to work around it ;-) I guess my original question should be answered as such? "No, you cannot specify a different configuration file name other than php.ini, you must either hack the C code or supply a workaround at runtime." Monte On Thu, 2003-06-05 at 15:07, Mark wrote: Wrap it in a shell script or batch file. Something like: REM ---Start cli.bat--- ./cli/php.exe -c <> %1 %2 %3 %4 %5 %6 %7 %8 %9 @exit REM ---End cli.bat--- --- Monte Ohrt <[EMAIL PROTECTED]> wrote: Hi Adam, I know it can be altered with a command-line switch, but it is the default that I want to change. I don't want to have to remember to set the -c flag everytime, or go back and change all my existing scripts. Monte On Thu, 2003-06-05 at 09:53, Adam Voigt wrote: From a ./php -h: -c | Look for php.ini file in this directory The "|" means "OR", so logic would dictate you can point directly to the file with the -c option. On Thu, 2003-06-05 at 10:35, Monte Ohrt wrote: Hi Cal, I may be missing something, but I don't see how this page answers either of my questions. ini_set() is for setting configuration options. Monte On Thu, 2003-06-05 at 09:23, Cal Evans wrote: http://www.php.net/manual/en/function.ini-set.php * Cal Evans * http://www.christianperformer.com * Stay plugged into your audience * The measure of a programmer is not the number of lines of code he writes but the number of lines he does not have to write. * - Original Message - From: "Monte Ohrt" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Cc: <[EMAIL PROTECTED]> Sent: Thursday, June 05, 2003 9:22 AM Subject: [PHP] PHP CLI question Hi, A couple of questions: 1) Is there a way to make the CLI version of PHP ignore certain settings in the php.ini file? For instance, I don't want the ioncube accelerator invoked when using PHP from the command line. My current work around is to use two separate init files, php.ini and php-cli.ini ... and this brings me to my second question: 2) Is there a way to specify a different name for the php.ini file, apart from hacking php_ini.c ? It seems I can only change the _path_ to the file, but not the filename itself. TIA Monte -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Monte Ohrt <[EMAIL PROTECTED]> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php = Mark Weinstock [EMAIL PROTECTED] *** You can't demand something as a "right" unless you are willing to fight to death to defend everyone else's right to the same thing. *** __ Do you Yahoo!? Yahoo! Calendar - Free online calendar with sync to Outlook(TM). http://calendar.yahoo.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php