linux automatic mail with expect

Expect script sends me a mail to when someone logs in.

1. In .bash_profile
./.sendloggedin

2. In .sendloggedin
#!/usr/bin/expect
spawn telnet smtp.online.nl 25
send "ehlo smtp.online.nl\r"
expect "250 8BITMIME"
send "MAIL FROM: centos@groningen.nl\r"
expect "250 2.1.0 Ok"
send "RCPT TO: p.w@planet.nl\r"
expect "250 2.1.5 Ok"
send "data\r"
expect "354 End data with <CR><LF>.<CR><LF>"
send "someone logged in\r"
send ".\r"
expect "Ok"
send "quit\r"

This entry was posted in linux. Bookmark the permalink.

Comments are closed.