?
Solved

apache & PHP 'exec'??

Posted on 2010-11-27
6
Medium Priority
?
567 Views
Last Modified: 2012-05-10
Dear all:

i try using with php 'exec' to execute a linux command. but it given non-response (not output).

but once i run the command with ssh, not problems on the command.

beside that i have check audit.log, can't found any log related. And i was add permission under sudoers file.

apache  ALL=NOPASSWD:/usr/local/bin/tesseract   ALL


can any one guide how to troubleshoot? I was try with & without SELINUX.


thanks.
0
Comment
Question by:simonlai
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 18

Expert Comment

by:Sudaraka Wijesinghe
ID: 34224198
Is it just not providing out put or command not executing at all?

To get an out put in exec you need to initialize the second parameter as an array.

$output=array();
exec('/command/here', $output);

Open in new window

0
 
LVL 1

Author Comment

by:simonlai
ID: 34224227
thanks for reply. sudaraka.

The command wiill generate a txt file in the direction. But it was not. Even i disabled SELINUX, still not able to run the command with apache.

I checked the direction, the permission was open.


thanks.
0
 
LVL 1

Author Comment

by:simonlai
ID: 34224229
this my command

exec("tesseract /var/www/html/ipc/ocr/".$destination." /var/www/html/ipc/ocr/uploadfile/".$nameFile."");

Open in new window

0
WordPress Tutorial 1: Installation & Setup

WordPress is a very popular option for running your web site and can be used to get your content online quickly for the world to see. This guide will walk you through installing the WordPress server software and the initial setup process.

 
LVL 18

Accepted Solution

by:
Sudaraka Wijesinghe earned 2000 total points
ID: 34224269
You can use the 3rd parameter on exec to get the error code returned from the OS, check that to see if you get something meaningful.
$error=0;
$output=array();

exec("tesseract /var/www/html/ipc/ocr/".$destination." /var/www/html/ipc/ocr/uploadfile/".$nameFile."", $output, $error);

echo "Error: $error";

Open in new window

0
 
LVL 1

Author Closing Comment

by:simonlai
ID: 34224338
thanks for your guide...... sudaraka
0
 
LVL 18

Expert Comment

by:Sudaraka Wijesinghe
ID: 34224389
You are welcome, Thanks for the points.
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
This article discusses how to create an extensible mechanism for linked drop downs.
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

771 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