首页 > 解决方案 > Issues Running Bash Script with PHP Parameters

问题描述

I am controlling LED's on a RPI 3 B Vi2 using a php script on another machine on a chatbot (DialogFlow). On the PHP script I have a command that calls the script on the RPI from the /var/www/html directory. The bash script is simple, it contains the following:

#!/bin/bash


echo "gpio -1 mode $1 out" | at $3

echo "gpio -1 write $1 $2" | $3

That's it. the command that calls this on the php script is:

echo exec('./script.sh 7 1 $Time', $output, $return);

print_r($return);

The command works if you substitute '$Time' with an actual figure but does not work using parameters (I have tried different types of variables too). Does anybody have any knowledge that could be beneficial to me regarding this matter?

Many thanks.

标签: phpbash

解决方案


推荐阅读