Shell script fails when executed via php

Hi Everyone,

I have written a script using shell and uemcli(Unity/EMC), which executes fine from backend. But, when I execute the same script using php i.e frontend, it fails.

Below is the code:

shell script code-

uemcli -d 11.11.22.33 -u test -p [email protected] /env/sp show
uemcli -d 11.11.22.33 -u test -p [email protected] /env/disk show

These are the commands that works fine in black screen. But it doesn't execute when called using php. There is no error being shown in apache error logs or in /var/log/messages.

Below is the code of php file

#!/bin/sh

{ shell_exec("/bin/sh /test/test.sh"); }
 


kenJackson

Member
That doesn't look like a php file.

I've done minimal php and no longer have the php command line installed. But judging from this reference, this might be closer to what you want:

Code:
#!/usr/bin/php
<?php
shell_exec("/bin/sh /test/test.sh");
?>
 

wizardfromoz

Super Moderator
Staff member
Gold Supporter
G'day @Yashwant Shettigar and welcome to linux.org :)

Thanks, too, Ken, for that input.

I am moving this Thread to Command Line, which is where scripting enquiries are also most frequently asked and answered.

Good luck, and enjoy your Linux

Chris Turner
wizardfromoz
 

Members online


Top