Dicki Rizki Amarullah
Dicki Rizki Amarullah

Reputation: 11

how run bash script with php shell_exec with passing 2 variable parameter

i want running bash script with passing 2 parameter and show with bash script create file.txt

$email = "omdik";
$password = "123";

$page = shell_exec("/var/www/html/aktiva-development/test.sh $email, $password");

and this file test.sh

#!/bin/bash
echo "username : $1 dan password : $2" > /tmp/cekhasil.txt

why the file not create, like the bash command is not running, but if script bash like ls dir the dir list will be show, and the access permision for file and folder i was change to 777

thank you for help.

Upvotes: 0

Views: 111

Answers (2)

Dicki Rizki Amarullah
Dicki Rizki Amarullah

Reputation: 11

Hei all i am already solve for this case, solve with change access permision folder and file to www-data:www-data for sh file and php file

-rwxrwxrwx 1 www-data www-data test.sh and 
-rw-r--r-- 1 www-data www-data file.php

thanks all for answer

Upvotes: 1

Armali
Armali

Reputation: 19405

in line 49 is bash script $page = shell_exec(‘/var/www/html/aktiva-development/test.sh “$email”, “$password”’);

You have wrong , , and quotes there; you have to use ' and ".

Upvotes: 1

Related Questions