Starting a a bash file with php

Hi

On one server with centos 5, 32 bit, php 5.3, we have FMS and we want to control it from an external site, we need to restart it sometimes.
we created a file fms-start.sh with the below code

#!/bin/bash
/opt/adobe/fms/server restart

it works, if we login to root of the server and we run this file fms restarts.

then on the same folder /var/www/html
we created a php file restart.php with the below code:

<?php
exec(bash fms-restart.sh);
?>

but it doesn’t work, the error if I run this file on root is

[root@fms3 html]# php restart.php
PHP Parse error: syntax error, unexpected T_STRING in /var/www/html/restart.php on line 2

this may be very simple, I am not a php coder, I’m just a server administrator, Linux, cpanel, ffmpeg, red5, wowza and fms, so my apologies, if I’m asking a real stupid question.

Thanks

why you run php file.maybe run bash file.bash file include php code.
i’m not sure can run php file directly under linux

exec('bash fms-restart.sh');

As an administrator I’m sure you’re aware that allowing command line execution of commands at the application layer opens up the server and possibly the entire network to security vulnerabilities. right? So I’m assuming proper precautions have been taken to mitigate the security vulnerabilities of allowing this.

I want to call this file restart.php on the browser.

yes, it will be on a protected directory. with a number of security layers.

your code improved the situation, if I run the file on shell:
[root@fms3 html]# php restart.php
the fms restarts, but if I call it on the browser nothing happens.

As a server administrator, are you aware of a sudo command?

On shell I run as root.

That is not the problem, the problem is how to run the file with php from the browser.

Thanks

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.