首先,我是新手,期待脚本......
我正在使用 RHEL 5.6 Linux。
我想从 bash 脚本中调用一个期望脚本并将其传递两个参数,一个主题和一个正文变量(从文件中读取并存储在其中),以便期望脚本发送带有该主题和正文的电子邮件。
使用_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