bash - 期待と変数

bash - 期待と変数

私は以下を持っています:

while read line; do
    userinfo=$(echo $line | sed 's/@/,/')
    IFS=',' read -a address <<< "$userinfo"
    userid="${address[0]}"
    domain="${address[1]}"
    fname="${address[2]}"
    lname="${address[3]}"
    #status=xxx
    SMTPlist=$(host $domain | grep "handled by" | awk '{print $7}' | sed 's/\.$//' )
    address=("${address[@]}" $SMTPlist) 

    #echo $email ---- $domain ---- $fname ---- $lname
    /usr/bin/expect << EOF
    set timeout 1
    #set echo on
    #log_user 0

    spawn telnet ${address[4]} $telnetport
    expect "220"

    send "helo $domain\r"
    expect "service"

    send "mail from: <[email protected]>\r"
    expect "250"

    send "rcpt to: <$userid@$domain>\r"
    expect {
        "250"   {
                send_user "$userid@$domain validation SUCCESSFUL\n"
                **set status "SUCCESSFUL"
                puts "status = \$status"**
                }
        "230" {send_user "ACCESS denied validation UNSUCCESSFUL\n"}
        "550" {send_user "$userid@$domain validation UNSUCCESSFUL\n"}       
        "553" {send_user "Requested action nottaken validation UNSUCCESSFUL\n"}     
    }

    send "quit"
    expect "closed"
EOF
    printf "$body" "$userid" "$domain" "$fname" "$lname" "$status"
 done < $emaillist

EXPECTのwhileループに変数を設定し、bashとして返したいと思います。

                **set status "SUCCESSFUL"
                puts "status = \$status"**

構文が正しいか、何か抜けているかどうかはわかりません。どんな意見でも高く評価いたします。ありがとうございます。

ベストアンサー1

おすすめ記事