LinuxQuestions.org
Register a domain and help support LQ
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

Tags used in this thread
Popular LQ Tags ,

Reply
 
Thread Tools
Old 09-23-2009, 03:26 PM   #1
pinwilinux
LQ Newbie
 
Registered: Sep 2009
Posts: 2
Thanked: 0
Unhappy How use shell_exec funtion in php 5.2.5 over linux


[Log in to get rid of this advertisement]
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.
windows_xp_2003 pinwilinux is offline  
Tag This Post ,
Reply With Quote
Old 09-23-2009, 03:37 PM   #2
nc3b
Member
 
Registered: Aug 2005
Posts: 327
Thanked: 2
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 03:38 PM..
windows_xp_2003 nc3b is offline     Reply With Quote
Old 09-23-2009, 05:25 PM   #3
pinwilinux
LQ Newbie
 
Registered: Sep 2009
Posts: 2
Thanked: 0

Original Poster
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.
windows_xp_2003 pinwilinux is offline     Reply With Quote
Old 09-24-2009, 01:51 AM   #4
nc3b
Member
 
Registered: Aug 2005
Posts: 327
Thanked: 2
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 01:53 AM..
windows_xp_2003 nc3b is offline     Reply With Quote

Reply

Bookmarks


Thread Tools

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


All times are GMT -5. The time now is 06:34 AM.

Main Menu
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
RSS2  LQ Podcast
RSS2  LQ Radio
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration