まず第一に、私はスクリプトを期待するのは初めてです...
RHEL 5.6 Linux を使用しています。
期待スクリプトがその件名と本文を含む電子メールを送信するために、bash スクリプトから expect スクリプトを呼び出し、2 つの引数、件名と本文変数 (ファイルから読み取り、そこに格納) を渡したいと考えています。
use_expect.sh:
#!/bin/bash
body=`cat body.txt`
subj="whatever bla bla"
./mail.exp $subj $body
メール.exp:
#!/usr/bin/expect -f
set subj [lindex $argv 0];
set body [lindex $argv 3]; # here we see also: instead of 1 I have to use 3 to skip all the subj words
spawn telnet localhost 25
.
.
.
send "mail from:...\n"
send "rcpt to:...\n"
send "data\n"
send "Subject: $subj\n" # only the first word is being sent!!!
send "$body\n" # also only the first word is being sent!!!
...
send "quit\n"
interact