LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 11-18-2003, 11:24 PM   #1
J_Szucs
Senior Member
 
Registered: Nov 2001
Location: Budapest, Hungary
Distribution: SuSE 6.4-11.3, Dsl linux, FreeBSD 4.3-6.2, Mandrake 8.2, Redhat, UHU, Debian Etch
Posts: 1,126

Rep: Reputation: 58
PHP: what's wrong with this line (shell_exec, find, xargs, grep)?


The commands below only return any output, if the total length of filenames returned by the find command and piped to the grep command is less then cca. 50kB:

$strCmd = 'find ' . $mappa . ' -name "' . $strFilename . '" -type f -print | xargs grep -l -i -E "' . $strText . '"' ;
$strList = shell_exec($strCmd)

Edited:

Sorry, it turned out that the problem is caused by a subsequent command, which is:
$strCmd1 = 'echo ' . $strList . ' | xargs grep -l -i -E "' . strText1 . '"'

The problem is, I think, that $strList may contain too long data to be passed to echo as argument.

But, if I cannot use echo, how to pass the value of $strList to grep???

Last edited by J_Szucs; 11-18-2003 at 11:51 PM.
 
Old 11-19-2003, 01:05 AM   #2
Bluesuperman
Member
 
Registered: Nov 2002
Distribution: Slackware
Posts: 155

Rep: Reputation: 30
Try this instead:

exec("/usr/local/bin/sar | grep Average | gawk '{print $3 \"\\n\" $4 \"\\n\" $5 \"\\n\" $7}'",$sarout);

$user = $sarout[0];
$nice = $sarout[1];
$syst = $sarout[2];
$idle = $sarout[3];
 
Old 11-19-2003, 09:03 AM   #3
J_Szucs
Senior Member
 
Registered: Nov 2001
Location: Budapest, Hungary
Distribution: SuSE 6.4-11.3, Dsl linux, FreeBSD 4.3-6.2, Mandrake 8.2, Redhat, UHU, Debian Etch
Posts: 1,126

Original Poster
Rep: Reputation: 58
> /usr/local/bin/sar

My system does not seem to have this tool. What is it for?

In the meantime I could solve the problem by saving the output of every single search in a temporary file, and using that as the input of the next search.
I think, however, that this could be faster if no disk access was necessary. Though - who knows if there is any...
 
Old 11-19-2003, 07:44 PM   #4
Bluesuperman
Member
 
Registered: Nov 2002
Distribution: Slackware
Posts: 155

Rep: Reputation: 30
the "usr/local/bin/sar" is just the command I am running, you can replace it with what ever command you want.

Check out http://perso.wanadoo.fr/sebastien.godard/

Is it a system stats utility -- provides great information.

Michael
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Run PHP shell_exec as root maneeshsethi Linux - General 5 12-30-2008 07:25 AM
php "shell_exec" how to handle prompts ALInux Programming 3 11-06-2005 04:13 AM
du on specific files from find command (use xargs?) fireman949 Linux - Software 2 07-10-2005 01:42 AM
PHP exec() and shell_exec() and SELinux Cottsay Programming 1 06-25-2005 09:47 PM
error with find . | xargs cbonar Linux - Newbie 7 12-09-2004 11:22 AM


All times are GMT -5. The time now is 03:31 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration