LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
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 09-23-2009, 02:26 PM   #1
pinwilinux
LQ Newbie
 
Registered: Sep 2009
Posts: 2

Rep: Reputation: 0
Unhappy How use shell_exec funtion in php 5.2.5 over linux


Hi I am new in php and try to use shell_exec function but don't work properly, the problem is donīt show any message error. my script is

$cli = "/public_html/newcli";
$dat = "-P/public_html/";
$execute = $cli." aut ".$tarjeta." ".$mesexpira." ".$anexpira." ".$monto2." ".$dat;
$cliresult = shell_exec($execute);

in variable &cli search a newcli file
in variable $dat search a cgi.dat file
in variable $clireult sow result of process

but donīt show anything, I think if can not find the folder should be display an error, but does not give me any error and not run the process

please help me.

Thanks.
 
Old 09-23-2009, 02:37 PM   #2
nc3b
Member
 
Registered: Aug 2005
Posts: 330

Rep: Reputation: 32
Smile

Welcome to LQ!

Try echo'ing $execute before shell_exec.. Also try running a simpler command (ls comes to mind..) at first

www.php.net
Quote:
Note: This function is disabled when PHP is running in safe mode
Don't want to be a nag, but you do realize, it's _quite_ unsafe.

HTH, Cheers

Last edited by nc3b; 09-23-2009 at 02:38 PM.
 
Old 09-23-2009, 04:25 PM   #3
pinwilinux
LQ Newbie
 
Registered: Sep 2009
Posts: 2

Original Poster
Rep: Reputation: 0
Unhappy Thanks for help

Tanks but not understand your response, sorry I am very very new in php, this is my first experience in php, if you could expand a little more your response, I appreciate.
 
Old 09-24-2009, 12:51 AM   #4
nc3b
Member
 
Registered: Aug 2005
Posts: 330

Rep: Reputation: 32
Hello, sorry for answering so late. Here's what you should do:
1. Make sure this function is available to you:


PHP Code:
<?
    $answer 
shell_exec('ls');
    echo(
$answer);
?>

2. Then, if that works:

PHP Code:
<?
    $cli 
"/public_html/newcli";
    
$dat "-P/public_html/";
    
$execute $cli." aut ".$tarjeta." ".$mesexpira." ".$anexpira." ".$monto2." ".$dat;
    
# $cliresult = shell_exec($execute);
    
echo($execute);
?>

You will see the command as it would be run by shell_exec. Try running it by hand and see what happens. Cheers

Last edited by nc3b; 09-24-2009 at 12:53 AM.
 
  


Reply

Tags
functions, php



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 07:25 AM
Linux and PHP mail() funtion malonesam Programming 1 05-17-2007 09:53 AM
shell_exec() and friends terminate PHP script (or time out?) MicahCarrick Programming 3 09-05-2006 04:37 AM
php mail() funtion in chrooted Apache clau_bolson Linux - Software 0 12-06-2005 10:02 AM
PHP exec() and shell_exec() and SELinux Cottsay Programming 1 06-25-2005 09:47 PM

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

All times are GMT -5. The time now is 09:01 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