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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
11-19-2003, 12:24 AM
|
#1
|
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:
|
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.
|
|
|
11-19-2003, 02:05 AM
|
#2
|
Member
Registered: Nov 2002
Distribution: Slackware
Posts: 155
Rep:
|
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];
|
|
|
11-19-2003, 10:03 AM
|
#3
|
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:
|
> /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...
|
|
|
11-19-2003, 08:44 PM
|
#4
|
Member
Registered: Nov 2002
Distribution: Slackware
Posts: 155
Rep:
|
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
|
|
|
All times are GMT -5. The time now is 01:41 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|