1

I want to run sendmail command inside the awk, but I got the error below.

awk command

awk '{ split($0,array,"@"); gsub("\."," ",array[1]); system("sendEmail -f foo@boo.com -t " $1 "-u \"Hello from command\" -m \"Dear\ " array[1] \"-s smtp.boo.com:587 -xu khikho -xp khikho"}' email_list.txt

error:

syntax error near unexpected token('`

email_list.txt head:

user.1@boo.com

user.2@boo.com

user.3@boo.com

Thank you in advance.

4

1 に答える 1

3

これは、すべての引用符を正しく取得するのがそれほど難しくない、わずかに異なるアプローチです (まったく使用せずawk、 の文字列解析機能のみを使用しますbash)。

while read address
do
  user=${address%%@*}
  sendEmail -f foo@boo.com -t ${address} -u "Hello from command" -m "Dear ${user}" \
       -s smtp.boo.com:587 -xu khikho -xp khikho
done < email_list.txt
于 2013-06-11T20:46:19.627 に答える