yezi <> wrote:
Y> while( <FILE> ) {
Y> my $cmdline="wget -w 50 -q http://$_ & tcpdump -c 20 -i eth0
src host $_ -w $_.dmp ";
Y> system($cmdline);
Ian Wilson <> suggested:
IW> You may want to check that $cmdline actually contains what you
IW> think it does.
This is an excellent suggestion.
Y> I try to run it, by using the & the waring message is :
Y> syntax error near unexpected token `&'
Y> sh: -c: line 2: ` & tcpdump -c 20 -i eth0 src host
www.cron.com'
IW> The "sh" at the beginning means that this is not a perl error message,
IW> it is a shell error message. your system call passes your command
IW> to the shell. This means that this isn't really a perl question.
Actually, in this case it is a perl related problem. The hint is that
sh is complaining about line 2. I'll wager that the OP didn't expect
there to be more than one line in their system() shell call.
IW> I'd try typing your command into a shell command line before embedding
IW> it in a perl script.
The command will work, because it won't be exactly the same as what's
passed via system(). It's Yezi's misunderstanding of what it returned
from <FILE> that's at fault here.
Yezi, I suggest you go and read "perldoc -f chomp" and see if that helps
resolve the problem you're seeing.
Chris