Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #14984
| From | Ben Bacarisse <ben.usenet@bsb.me.uk> |
|---|---|
| Newsgroups | comp.lang.php |
| Subject | Re: Run AWK using shell_exec |
| Date | 2015-02-27 02:23 +0000 |
| Organization | A noiseless patient Spider |
| Message-ID | <87egpcozxq.fsf@bsb.me.uk> (permalink) |
| References | <bd5897d2-065d-4cf1-bd7f-cbcb3404cb25@googlegroups.com> <mcoev3$bt4$1@dont-email.me> <98db9ab8-dec1-4b3a-b790-285e967c64bb@googlegroups.com> |
"Dan'l B" <dan.hinckley@gmail.com> writes:
<snip>
> Substituting a variable containing a path-to-the file, I can't seem to
> get the escaping right:
>
> Works:
> $maxLow = shell_exec("/usr/bin/awk 'min==\"\" || $4~/^[^[:alpha:]]+$/
> && $4 < min {min=$4} END{print min}' fullyear.txt");
>
> Fails: (where $tidesFilePath is an absolute path to the fullyear.txt file).
> $tidesFilePath = "/Tidefiles/fullyear.txt"; (example path)
> $maxLow = shell_exec("/usr/bin/awk 'min==\"\" || $4~/^[^[:alpha:]]+$/
> && $4 < min {min=$4} END{print min}'" . $tidesFilePath . \"");
That's not syntactically correct PHP. I'm not sure what the . \"" bit
at the end is supposed to do, but you don't need it. You *do* need a
space between the end of the awk script in single quotes and the file
name:
... $4 < min {min=$4} END{print min}' " . $tidesFilePath);
But you should be very careful when including variables into a shell
command. Never forget little Bobby Tables http://www.xkcd.com/327/
--
Ben.
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