running a perl script from bash script with variable arguments

时间:2015-09-30 23:18:49

标签: bash perl

Hi I'm trying to write a simple script that takes 2 arguments and runs a perl script with the provided input

agents=$1
group=$2
while read agent
do
perl perlscript.pl perlconfig.conf --update_agent $agent group_name $group  
done < $agents

when I run this perl script on the command line with hand typed variables it works fine. However when running the script I get an error from the perl script that the update_agent command is expecting 3 arguments but is given 4. I can't seem to figure out where the 4th variable is coming from. Any help is appreciated thanks

1 个答案:

答案 0 :(得分:3)

至少,

perl perlscript.pl perlconfig.conf --update_agent $agent group_name $group

应该是

perl perlscript.pl perlconfig.conf --update_agent "$agent" group_name "$group"

唯一的问题是什么?不知道。你的工作太少了。