Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

inexplicable PHP behaviour(!?)

Posted on 2008-06-12
8
Medium Priority
?
179 Views
Last Modified: 2013-12-13
i have a snippit of PHP code which refuses to do the biz and i cannot for the life of me see why...
there is a simple (bespoke) binary ('mybin') which has 755 permissions and which maps an input string to stdout, eg:  %  echo "my_string" | mybin > outfile  ... which works fine as a shell cmd...

now in my php script i coded both:
     exec("echo $string_var | mybin > outfile");
and
     exec("cat text.file | mybin > outfile");
... but each of these produce empty output files... i have plenty other 'exec's in my script which are fine... the darn' thing just seems to want to ignore 'mybin' (which was built on the host m/c)... i even tried restarting the apache httpds...  ...no comprendo...  


 

0
Comment
Question by:shallxrg
  • 5
  • 2
8 Comments
 
LVL 4

Expert Comment

by:afzz
ID: 21771543
Instead of exec try the following if it works. Also try putting the full path to echo & cat like /bin/cat
`echo $string_var | mybin > outfile`;
`cat text.file | mybin > outfile`;

Open in new window

0
 
LVL 9

Accepted Solution

by:
Rurne earned 500 total points
ID: 21771672
Where is 'mybin' saved at?  If you have anything like open_basedir or include_path in play and mybin is not in your DocumentRoot, you may simply not be able to see where the program is.
0
 

Author Closing Comment

by:shallxrg
ID: 31466614
thanks rurne... but see the comment i added for general view
cheers
roger
0
Configuration Guide and Best Practices

Read the guide to learn how to orchestrate Data ONTAP, create application-consistent backups and enable fast recovery from NetApp storage snapshots. Version 9.5 also contains performance and scalability enhancements to meet the needs of the largest enterprise environments.

 

Author Comment

by:shallxrg
ID: 21776965
rurne's solution was 'correct'... i moved 'mybin' from '/bin' to the docroot directory, and bingo... however, i cannot understand why the shell() and backtick commands can cheerfully invoke other executable binaries from /bin (eg gunzip) and yet not the bespoke binary 'mybin' .... permissions were ok ... still don't understand!
0
 

Author Comment

by:shallxrg
ID: 21777165
this is quite possibly a nugget of info... i just discovered that the PHP shell() command WILL run my executable from /bin but ONLY if the binary is stripped(!!?!!)... (it will run it from the docroot directory whether or not it is stripped)

i simply did :  strip -s '/bin/mybin' and off she went....

WEIRD!
0
 

Author Comment

by:shallxrg
ID: 21778591
cancel that last post... i think i just got confused
0
 
LVL 9

Expert Comment

by:Rurne
ID: 21781039
I'd highly recommend checking your Apache configuration for any open_basedir or include_path directives.  Alternatively, you could be running in safe mode, which is not recommended (and deprecated in current versions of PHP for its bugginess).  That would be why you could access something from the command line and not from CGI or ISAPI mode.

HTH.
0
 

Author Comment

by:shallxrg
ID: 21785508
check.... thanks for the tip... i'll do that next i'm back in the office... today is saturday and SUNNY :-)
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
It’s a season to be thankful, and we’re thankful for users like you who engage on site, solve technology problems, and network with others in the industry. What tech are we most thankful for? Keep reading.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Suggested Courses
Course of the Month20 days, 21 hours left to enroll

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question