J'ai un script bash:
#!/bin/bash
#set -x
echo -n "Enter the Name: "
read name
echo -n "Enter the age: "
read age
echo "$name is $age"
J'ai un script PHP qui l'appelle:
Comment puis-je le passer le name
et age
paramètres? Notez que je ne peux pas modifier le script shell lui-même!
Merci!
Réponses:
1 pour la réponse № 1A partir du script PHP, créez d'abord un fichier d'entrée temporaire:
$ echo sharad > my_input_file
$ echo 20 >> my_input_file
#######################
$ cat my_input_file
sharad
20
#######################
$ cat my.sh
#!/bin/bash
#set -x
echo -n "Enter the Name: "
read name
echo -n "Enter the age: "
read age
echo "$name is $age"
#######################
$ cat my_input_file | ./my.sh
Enter the Name: Enter the age: sharad is 20
#######################