Shell script fails when executed via php

Yashwant Shettigar

New Member
Joined
Mar 25, 2019
Messages
1
Reaction score
0
Credits
0
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 test@123 /env/sp show
uemcli -d 11.11.22.33 -u test -p test@123 /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"); }
 


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");
?>
 
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
 

Staff online

Members online


Latest posts

Top