想通过php文件传递bash文件中的参数

时间:2014-04-03 11:46:13

标签: php linux bash arguments

PHP代码:

$number_server = 10;
exec("/bin/bash wrun.sh $number_server",$wuptime);

Bash脚本:

 #!/bin/sh
 for i in `seq echo $1`; do
     ssh /usr/local/bin/wrun 'uptime
     ps -elf | grep httpd | wc -l
     free -       m;mpstat'
 done &

 pid=$!
 sleep 3
 kill -9 $pid && echo "not respond in give time"

在此我想将参数$number_server从php文件传递给bash脚本。

1 个答案:

答案 0 :(得分:1)

#!/bin/sh
for i in `seq $1`; do