473,396 Members | 2,052 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

find and Exec statment in PHP not working

123 100+
Hi All,
I have a page in which user can enter first name,last name , date and according to that My script should search for the records which matches the above last n first names and print it.
I have the below code,
But seems not working..
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. $title = " Form";
  3. echo "Hello";
  4.  if(isset($_POST['fname'])) { $f1 =  $_POST['fname']; }
  5.  
  6. if (isset($_POST['lname'])) { $ll =  $_POST['lname']; }
  7. if (isset($_POST['add'])) { $a1 =  $_POST['add']; }
  8. if (isset($_POST['date'])) { $d1 =  $_POST['date']; }
  9.  
  10. $fullname = $l1.","f1;
  11. echo "$fullname;
  12. $dirname = "/home/gr/ereports/O1"  ;
  13.  
  14. $handle = opendir($dirname) or print "cant open";
  15.  
  16. $ans = shell_exec("find /home/gr/ereports/O1/$d1 -name \*.ps  -exec grep -i -e "$fullname" {} \;  -print; ");
  17.  
  18. ?>
  19.  
  20.  
If i go on shell to home/gr/ereports/O1 and then write the code as below
Expand|Select|Wrap|Line Numbers
  1. find dirname -name "*.ps" -exec grep -i -e "CAK, SO" {} \; -print ;
  2.  
Here in above "CAK , SO" in which CAK is the lastname n SO is the first name
its giving me the result perfectly.
I am thinking that the way I used the above statment in PHP is wrong..
Can anybody help me...
Thanks
Sep 12 '08 #1
3 2610
Atli
5,058 Expert 4TB
Hi.

There are a lot of syntax errors in that code.
Try turning on the debug messages and fix the errors. See if that helps.
Sep 13 '08 #2
ajd335
123 100+
Hi..
Oh m sorry..have posted that with making some changes..And thus , it has so many syntax errors..
When I execute the below on shell it works fine...
Expand|Select|Wrap|Line Numbers
  1. find /home/gr/ereports/O1/2008-06-17 -name "*.ps" -exec grep -i -e "LISA" {} \; -print ;
  2.  
And in PHP i am writing
Expand|Select|Wrap|Line Numbers
  1. $ans = shell_exec("find /home/gr/ereports/O1/$d1 -name /"/*.ps/"  -exec grep -i -e $l1  {} \;  -print; ");
  2.  
How can I write "*.ps" in shell_exec ..here I have used /"/*.ps/" back slashes..
Sep 16 '08 #3
pbmods
5,821 Expert 4TB
Heya, AJD.

Use these slashes: \ to escape quotes.
Sep 16 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Nick Jacobson | last post by:
This works fine: x = 1 def execfunc(): print x execfunc() So why doesn't this? s = \
1
by: Hennie de Nooijer | last post by:
Hi I'm executing SP_SpaceUsed in a stored procedure like this : Exec ('SP_SpaceUsed '+ @table) This works great but when i want to execute it for a table in a other database i'm running in...
6
by: philipdm | last post by:
I am building a SQL statement that returns a number. when I execute the Built SQL statment EXEC(@Build). What I need to do now is take that number that comes back and store it in another variable...
2
by: N. Pourcelot | last post by:
Hello, I can't understand some specific behaviour of the exec statment. For example, say that I create such a class A : class A: def __init__(self): self.n = 3 self.m = None def h(self,...
21
by: comp.lang.tcl | last post by:
set php {<? print_r("Hello World"); ?>} puts $php; # PRINTS OUT <? print_r("Hello World"); ?> puts When I try this within TCL I get the following error:
1
by: rickcasey | last post by:
I wonder if anyone has experienced something like this, as it seems truly bizarre and is causing me to tear out my hair (what little there is left of it).... The exec() function just suddenly...
2
by: ajd335 | last post by:
Hi all, When I use the "find" and "grep" command on SSH shell gives me correct results. But when i use the same line in PHP....It's not working. The line of code is find 2008-06* -name...
0
by: ajd335 | last post by:
Hi All, I am writing one find statement which gives me all the files related with the specific user name the user entered. my code looks like <?php $title = "Grading Form"; if(isset($_POST))...
23
by: Maarten | last post by:
Howdy, Recently I switched from a Windows PC to Mac OS-X 10.5 (php v5.2.6) and I have a little problem with one function within my cd-management script. For extracting a bit of info from my...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.