[Ilugc] how to execute .sh file in php

  • From: gnuyoga@xxxxxxxxx (Sreekanth B)
  • Date: Mon Feb 1 17:09:33 2010

hi

On Mon, Feb 1, 2010 at 4:24 PM, Kannan <kannan4k@xxxxxxxxx> wrote:

This is the shell script file is

//sendsms.sh
echo "Welcome" | gnokii --sendsms 9944047439
ls

php script is

</php
$n=exec("sh sendsms.sh ");
?>

these two files are located in /var/www/html/ in fedora


its been a while i used php, let me give it a try.

refer this to get the exact syntax to get it working
http://php.net/manual/en/function.shell-exec.php

now the next problem is is where this file exist, am not sure if php will
have default access to entire file system. if it has then best would be to
use full path eg: sh /var/www/html/sendsms.sh otherwise do a pwd from php
and find the base root. based on the output add the full/relative path to
script.

am sure other php hackers in the list can help u better, but this is perhaps
how i would tackle this problem. sorry for not able to provide u with exact
steps :-(

- sree

Other related posts: