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?

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

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

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.