0

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.

5
  • Did you try enclosing the arguments within double quotes? shell_exec(‘/var/www/html/aktiva-development/test.sh “$email”, “$password”’); Commented Jun 19, 2021 at 7:14
  • @Armali the algoritma, start from login form, and if the username and password is true the bach script will be run, else username and password is false nothing. Commented Jun 20, 2021 at 7:52
  • yeah i am already for trying that, but the script bash is the same not running, @abhishekphukan Commented Jun 20, 2021 at 7:53
  • 1
    hey i find that error if i runninh that @abhishekphukan the message error is PHP Parse error: syntax error, unexpected 'var' (T_VAR) in /var/www/html/aktiva-development/verifikasi_new.php on line 49, Commented Jun 20, 2021 at 7:55
  • 1
    in line 49 is bash script $page = shell_exec(‘/var/www/html/aktiva-development/test.sh “$email”, “$password”’); @Armali Commented Jun 20, 2021 at 8:44

2 Answers 2

1

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 ".

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

5 Comments

huahh my head hurts, the result is still the same can't and no error message what, idk again what i must doit
Proposal: add the line exec 2>&1 before the echo and inspect $page then after return in PHP.
i think the error is wording format shell exec passwing with 2 argument, because in file test.sh under line echo username and password i add echo string something it show in my website, do you now format wording with shell_exec from php and then get at the file test.sh the value
i already try this format but can't, do you have any reference? $page = shell_exec("/tmp/my_script.php $my_url $my_refer"); $page = shell_exec('/tmp/my_script.php "'.$my_url.'" "'.$my_refer.'"');
I don't understand what reference you mean.
1

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.