1

I have a script.sh with the following content:

#!/bin/bash
 echo You Name:
 read name
 echo You Age:
 read age
 echo Name: $name, Age: $age.

Is it possible to pass the name and age variables to the read shell script with php?

asked Jun 8, 2017 at 9:47
1
  • are tou created your .sh file using php Commented Jun 8, 2017 at 9:50

1 Answer 1

1

Yes you can Pass parameters to bash.

PHP:

$output = exec("./bashscript $name $age");
#!/bin/bash

Bash:

name=1ドル
age=2ドル

Reference: passing a variable from php to bash

answered Jun 8, 2017 at 9:55
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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.