2

Part 1

In my CentOS 7x, i have my C++ binary located in /var/tmp/sip-dialer/reminder-call.

Which is executed using following BASH

reminder-call.sh:

#!/bin/bash
cd /var/tmp/sip-dialer
./redminder-call -P sip -u GokuPower -c 1234 -w reminder.myvoipserver.com -x "call003248181919;wakeupItsMorning;sleep3000;hangup"

On execute the whole setup works perfectly fine (Part 1).

Part 2:

Now i need to call my BASH script from Android, iOS, Tizen and via other WebServices such as https://cow:[email protected]/run.php .

So in my ZF2, PHP i have following:

<?php
$output = shell_exec('/home/www/html/sip-phone/reminder-call.sh');
echo "executed";
?>

When i call the PHP to execute that BASH script it fails to execute with following:

/home/www/html/sip-phone/reminder-call.sh: line 3: ./redminder-call: No such file or directory

What is happening? Manually BASH script works but involving PHP to execute the same thing is failing.

8
  • 1
    Have you checked your file permissions on /home/www/html/sip-phone/reminder-call.sh to see if php has access to /home/www/html/sip-phone/reminder-call.sh with privileges php has on execution? Commented Feb 22, 2018 at 10:45
  • chmod -R 777 /home/www/html/sip-phone/reminder-call.sh; chmod +x /home/www/html/sip-phone/reminder-call.sh; is set, but still giving error php "No such file or directory" Commented Feb 22, 2018 at 10:54
  • 1
    can you do ls -l /home/www/html/sip-phone/reminder-call.sh to see if your command has been applied to it? Commented Feb 22, 2018 at 10:56
  • -rwxrwxrwx 1 root root 142 Feb 22 10:19 /home/www/html/sip-phone/reminder-call.sh Commented Feb 22, 2018 at 10:58
  • 1
    Let us continue this discussion in chat. Commented Feb 22, 2018 at 11:04

1 Answer 1

1

You need to set the necessary permissions on /home/www/html/sip-phone/redminder-call as according to your output

/home/www/html/sip-phone/reminder-call.sh: line 3: ./redminder-call: No such file or directory

the script

/home/www/html/sip-phone/reminder-call.sh

works but with the current privileges either the file

/var/tmp/sip-dialer/redminder-call is missing or doesn't have the necessary privileges.

To check file exists please do

ls -l /var/tmp/sip-dialer/redminder-call

and if it's there and check it's permissions.

If the permissions are valid (eg. rwxrwxrwx), check that the parent folder(s) has enough privilege to traverse and execute the file. More info on parent folder/file permissions are here

Per your case

mv /var/tmp/sip-dialer /
chmod -R 777 /sip-dialer
chmod +x /sip-dialer/redminder-call

will do the trick. The problem is that /var/ is not accessible as the current permissions for php is not enough to traverse it (unless you set +x or 777 to /var which is highly unrecommended for security purposes)

Sign up to request clarification or add additional context in comments.

Comments