Jump to content

output from unix with php


Aretai

Recommended Posts

Hi,

 

I have a problem with displaying unix commands output in php. I use SunOS5, php4.

 

I try to put on the web content of the command

 

usr/local/aretai/grep -irU /opt/users/aretai/test/projects/*

 

This works - I get a list of the files some of them are binary so it's like:

 

Binary file /opt/users/aretai/test/projects/test.txt matches

Binary file /opt/users/aretai/test/projects/test1.txt matches

Binary file /opt/users/aretai/test/projects/test2.txt matches

Binary file /opt/users/aretai/test/projects/test3.txt matches

Binary file /opt/users/aretai/test/projects/test4.txt matches

 

Now I want to strip the unnecessary "Binary file" and "matches" in case they occur (sometimes they don't).

I tried to do it with :

 

echo "Binary file opt/users/test/projects/test.txt Matched" | 
sed "s/^.*aretai\([^ ]*\) .*/\1/"

 

Yes I know it's only for the one file, but when I put it in the:

 

shell_exec(" "Binary file opt/users/test/projects/test.txt Matched" | 
sed "s/^.*aretai\([^ ]*\) .*/\1/" ");

 

I get error T_STRING...

 

I tried diff things " 'Binary ...

etc.

 

I know it's necessary to escape single ' but how's with the "?

 

thx for answer

 

Aretai

Link to comment
https://forums.phpfreaks.com/topic/41309-output-from-unix-with-php/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.