LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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-19-2003, 12:24 AM   #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-19-2003 at 12:51 AM.
 
Old 11-19-2003, 02: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, 10: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, 08: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 08:25 AM
php "shell_exec" how to handle prompts ALInux Programming 3 11-06-2005 05:13 AM
du on specific files from find command (use xargs?) fireman949 Linux - Software 2 07-10-2005 02:42 AM
PHP exec() and shell_exec() and SELinux Cottsay Programming 1 06-25-2005 10:47 PM
error with find . | xargs cbonar Linux - Newbie 7 12-09-2004 12:22 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:41 PM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration