Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #14980
| From | Jerry Stuckle <jstucklex@attglobal.net> |
|---|---|
| Newsgroups | comp.lang.php |
| Subject | Re: Run AWK using shell_exec |
| Date | 2015-02-26 19:50 -0500 |
| Organization | A noiseless patient Spider |
| Message-ID | <mcoev3$bt4$1@dont-email.me> (permalink) |
| References | <bd5897d2-065d-4cf1-bd7f-cbcb3404cb25@googlegroups.com> |
On 2/26/2015 5:40 PM, Dan'l B wrote:
> Given a file with data such as
>
> 2015-12-24 22:02 12 9.87 feet High Tide
> 2015-12-25 03:33 12 -0.38 feet Low Tide
> 2015-12-25 06:11 12 Full Moon
> 2015-12-25 10:16 12 11.01 feet High Tide
> 2015-12-25 16:09 12 -1.29 feet Low Tide
>
> This awk command works to get the minimum value in col (excluding text):
>
> awk 'min=="" || $4~/^[^[:alpha:]]+$/ && $4 < min {min=$4} END{print min}' fullyear.txt
>
> but I am stuck about how to format it for shell_exec.
>
> For example, with full error reporting on, this seems to fail:
>
> $maxLow = shell_exec("/usr/bin/awk 'min=='' || $4~/^[^[:alpha:]]+$/ && $4 < min {min=$4} END{print min} fullyear.txt");
>
I'm not that familiar with awk syntax, but I can see why it doesn't work
- you're not passing the same parameters to awk from PHP as you use in
the command line.
Not tested, but something like this might work:
$maxLow = shell_exec(\''min=="" || $4~/^[^[:alpha:]]+$/ && $4 < min
{min=$4} END{print min}\' fullyear.txt');
Or
$maxLow = shell_exec("'min==\"\" || $4~/^[^[:alpha:]]+$/ && $4 < min
{min=$4} END{print min}' fullyear.txt");
--
==================
Remove the "x" from my email address
Jerry Stuckle
jstucklex@attglobal.net
==================
Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Run AWK using shell_exec "Dan'l B" <dan.hinckley@gmail.com> - 2015-02-26 14:40 -0800
Re: Run AWK using shell_exec Jerry Stuckle <jstucklex@attglobal.net> - 2015-02-26 19:50 -0500
Re: Run AWK using shell_exec "Dan'l B" <dan.hinckley@gmail.com> - 2015-02-26 17:21 -0800
Re: Run AWK using shell_exec "Dan'l B" <dan.hinckley@gmail.com> - 2015-02-26 17:41 -0800
Re: Run AWK using shell_exec Jerry Stuckle <jstucklex@attglobal.net> - 2015-02-26 20:51 -0500
Re: Run AWK using shell_exec Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-02-27 02:23 +0000
Re: Run AWK using shell_exec "Dan'l B" <dan.hinckley@gmail.com> - 2015-02-26 19:11 -0800
Re: Run AWK using shell_exec Matthew Carter <m@ahungry.com> - 2015-02-27 00:28 -0500
Re: Run AWK using shell_exec Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-02-27 11:14 +0000
Re: Run AWK using shell_exec Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-02-27 14:17 +0100
Re: Run AWK using shell_exec "Dan'l B" <dan.hinckley@gmail.com> - 2015-02-27 11:40 -0800
Re: Run AWK using shell_exec Jerry Stuckle <jstucklex@attglobal.net> - 2015-02-27 16:03 -0500
csiph-web