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?

Espector
  • 431
  • 2
  • 5
  • 17

1 Answers1

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

NID
  • 3,238
  • 1
  • 17
  • 28