Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/tensorflow/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
bash脚本循环遍历数组并使用arg运行php脚本_Php_Bash_Unix - Fatal编程技术网

bash脚本循环遍历数组并使用arg运行php脚本

bash脚本循环遍历数组并使用arg运行php脚本,php,bash,unix,Php,Bash,Unix,我有一个每天凌晨1:01在cron中运行的bash脚本bash脚本是: array_of_clients=(2 187 317 927 1863 2993 3077 3440 3444 3457 3459 3469 3484 3487 3494 3497 3522 3544 3551 3553) for i in "${array_of_clients[@]}" do echo "\nRunning Client - $i" php -f "/mnt/www/bin/sched

我有一个每天凌晨1:01在cron中运行的bash脚本bash脚本是:

array_of_clients=(2 187 317 927 1863 2993 3077 3440 3444 3457 3459 3469 3484 3487 3494 3497 3522 3544 3551 3553)

for i in "${array_of_clients[@]}"
do
    echo "\nRunning Client - $i"
    php -f "/mnt/www/bin/scheduled/import_client.php" $i
    echo "\nFinished Client - $i"
done
这个问题是,我不知道$I是否作为参数传递给php脚本。我做错什么了吗?如果我把$I放在“”中,它会说它找不到文件,因为文件名变成了/mnt/www/bin/scheduled/import_client.php 2


有人能帮忙吗

您可以在预定义的全局变量
$argv
中访问PHP脚本中的命令行参数。 在本例中,您的
$i
将作为
$argv[1]
找到

请尝试以下脚本:

<?php
global $argv;
var_dump($argv);
?>

您可以在预定义的全局变量
$argv
中访问PHP脚本中的命令行参数。 在本例中,您的
$i
将作为
$argv[1]
找到

请尝试以下脚本:

<?php
global $argv;
var_dump($argv);
?>