FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Re: DOS newlines (CR/LF) to Unix format
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: DOS newlines (CR/LF) to Unix format [message #171894 is a reply to message #171892] Thu, 20 January 2011 13:17 Go to previous messageGo to previous message
Luuk is currently offline  Luuk
Messages: 329
Registered: September 2010
Karma:
Senior Member
On 20-01-11 13:03, Bjarne Jensen wrote:
> On 2011-01-20 11:26, Thomas 'PointedEars' Lahn wrote:
>
>> Maybe. It depends on the permissions that the user running php(.exe) has
>> for those files.
>
> The user running the script is 'www-data'.
> But I'm lost in space when it comes to determining what permissions
> 'www-data' has or would need to exec other programs.
>
>
>> The main issue is that you need to quote the argument to awk(1) as it was
>> described (single-quotes to avoid shell expansion).
>
> I'm trying to sort that one out.
>
>
> /Bjarne


If you have this PHP-file:
<?php
exec('awk --version >awk.txt', $result, $retun_var);
print_r($result);
print "Return_var: $return_var <br>";

exec("awk '{ print $1 }' awk.txt", $two, $return_var);
print_r($two);
print "Return_var: $return_var <br>";
?>


The output should be:
Array ( ) Return_var:
Array ( [0] => GNU [1] => Copyright [2] => [3] => This [4] => it [5] =>
the [6] => (at [7] => [8] => This [9] => but [10] => MERCHANTABILITY
[11] => GNU [12] => [13] => You [14] => along ) Return_var: 0

(at least if your awk-version is "GNU Awk 3.1.6" ;)

If awk cannot be executed, the output will be:
Array ( ) Return_var:
Array ( ) Return_var: 2


--
Luuk
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: fatal error: cannot redeclare
Next Topic: getting file from <option>
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sat Nov 23 19:36:40 GMT 2024

Total time taken to generate the page: 0.05393 seconds