RE: [PHP] Getting line count of a text file

2007-09-13 Thread Greg Donald
On Wed, 12 Sep 2007, bruce wrote: > while you are correct in your assertion that the shell cmds provided are > specific to linux, What assertions? I didn't know I made one. It's common sense but I don't recall making an assertion and then asking you if it was correct. > your assertion/statement

Re: [PHP] Getting line count of a text file

2007-09-12 Thread mike
On 9/12/07, Chris <[EMAIL PROTECTED]> wrote: > bruce wrote: > > greg... actually, i was the one that said this. > Sure they can - enable safe-mode and it causes all sorts of weirdness > with running exec or system calls. not to mention shell commands expect to be in PATH, and if you hardcode in

Re: [PHP] Getting line count of a text file

2007-09-12 Thread Chris
bruce wrote: greg... while you are correct in your assertion that the shell cmds provided are specific to linux, your assertion/statement that the functions might be 'turned off' are fud... basic bash functions are inherently part of the shell Sure they can - enable safe-mode and it caus

RE: [PHP] Getting line count of a text file

2007-09-12 Thread bruce
eral@lists.php.net Subject: Re: [PHP] Getting line count of a text file On 9/12/07, Greg Donald <[EMAIL PROTECTED]> wrote: > Why? Shell commands are a lot less likely to change than the > current PHP function names. > > I'm aware the PHP function naming algorithm curre

Re: [PHP] Getting line count of a text file

2007-09-12 Thread mike
On 9/12/07, Greg Donald <[EMAIL PROTECTED]> wrote: > Why? Shell commands are a lot less likely to change than the > current PHP function names. > > I'm aware the PHP function naming algorithm currently remains a > secret, but without a doubt, someday someone _will_ crack it. I > personally hope t

Re: [PHP] Getting line count of a text file

2007-09-12 Thread Greg Donald
On Wed, 12 Sep 2007, mike wrote: > personally i try to use as little shell commands as possible, > especially stacked on top of each other in exec(). Why? Shell commands are a lot less likely to change than the current PHP function names. I'm aware the PHP function naming algorithm currently rem

Re: [PHP] Getting line count of a text file

2007-09-12 Thread Jim Lucas
Frank J. Schima wrote: Hi all, In PHP 5, I'm counting the number of lines in a text file using the following code: $myfile = file ( '/path/to/myfile.txt'); $count = count ($myfile); However, sometimes it fails with the following error: PHP Fatal error: Allowed memory size of

Re: [PHP] Getting line count of a text file

2007-09-12 Thread Frank J. Schima
Hi Gang, On Sep 12, 2007, at 1:58 PM, bruce wrote: if you're going to do the system approach, go ahead and use awk/cut... wc -l foo.txt | awk -F' ' '{print $1}' should work assuming you're on linux. I have solved the problem with this approach. Thanks for all the suggestions. FYI,

Re: [PHP] Getting line count of a text file

2007-09-12 Thread Per Jessen
Frank J. Schima wrote: > In PHP 5, I'm counting the number of lines in a text file using the > following code: > $myfile = file ( '/path/to/myfile.txt'); > $count = count ($myfile); > > However, sometimes it fails with the following error: > PHP Fatal error: Allowed memory size of bytes exh

Re: [PHP] Getting line count of a text file

2007-09-12 Thread mike
personally i try to use as little shell commands as possible, especially stacked on top of each other in exec(). i'd just use explode, str_split, substr/strpos, etc. after i got it back. On 9/12/07, Wolf <[EMAIL PROTECTED]> wrote: > Novel approach... But mine's less typing. :) > > never thought

RE: [PHP] Getting line count of a text file

2007-09-12 Thread Wolf
7; '{print $1}' > > should work assuming you're on linux. > > > > -Original Message- > From: mike [mailto:[EMAIL PROTECTED] > Sent: Wednesday, September 12, 2007 12:46 PM > To: Frank J. Schima > Cc: php-general@lists.php.net > Subject

RE: [PHP] Getting line count of a text file

2007-09-12 Thread bruce
2:46 PM To: Frank J. Schima Cc: php-general@lists.php.net Subject: Re: [PHP] Getting line count of a text file On 9/12/07, Frank J. Schima <[EMAIL PROTECTED]> wrote: > In PHP 5, I'm counting the number of lines in a text file using the > following code: > $myfile

Re: [PHP] Getting line count of a text file

2007-09-12 Thread Wolf
We all know REAL servers are *nix... :) And his path is *nix based... :) Nathan Nobbe <[EMAIL PROTECTED]> wrote: > On 9/12/07, Wolf <[EMAIL PROTECTED]> wrote: > > > > $command= escapeshellcmd("cat {$file} | wc -l"); > > // Run command and capture results > > $count = exec($com

Re: [PHP] Getting line count of a text file

2007-09-12 Thread Frank J. Schima
On Sep 12, 2007, at 1:46 PM, Nathan Nobbe wrote: On 9/12/07, Wolf <[EMAIL PROTECTED]> wrote: $command= escapeshellcmd("cat {$file} | wc -l"); // Run command and capture results $count = exec($command); that would work on *nix, but not windows. Since I am developing and deploying

Re: [PHP] Getting line count of a text file

2007-09-12 Thread Nathan Nobbe
On 9/12/07, Wolf <[EMAIL PROTECTED]> wrote: > > $command= escapeshellcmd("cat {$file} | wc -l"); > // Run command and capture results > $count = exec($command); that would work on *nix, but not windows. "Frank J. Schima" <[EMAIL PROTECTED]> wrote: > > Hi all, > > > > > > In PHP

Re: [PHP] Getting line count of a text file

2007-09-12 Thread mike
On 9/12/07, Frank J. Schima <[EMAIL PROTECTED]> wrote: > In PHP 5, I'm counting the number of lines in a text file using the > following code: > $myfile = file ( '/path/to/myfile.txt'); > $count = count ($myfile); > > However, sometimes it fails with the following error: >

Re: [PHP] Getting line count of a text file

2007-09-12 Thread Wolf
$command= escapeshellcmd("cat {$file} | wc -l"); // Run command and capture results $count = exec($command); "Frank J. Schima" <[EMAIL PROTECTED]> wrote: > Hi all, > > > In PHP 5, I'm counting the number of lines in a text file using the > following code: > $myfil