Good evening guys, I have an activity to do that needed me to use Expect to remove the user interaction in an SMTP communication. So in the body of the email I need to add the current date and size of a file. the code is like this
#!/usr/bin/expect
puts "Enviando e-mail para Administrador!!"
spawn telnet 192.168.0.102 25
expect "%"
send "helo script.com.br\r"
expect "%"
send "mail from: [email protected]\r"
expect "%"
send"rcpt to: [email protected]\r"
expect "%"
send "data\r"
expect "%"
send "Backup concluido com sucesso\r"
send ".\r"
expect "%"
send "quit\r"
expect eof
But I wish he would receive this command here but I do not know how to do it
#!/usr/bin/expect
DATA=$(date)
TAMARQ=$(ls -l | grep "arquivo_bakcup" | awk '{print $5}')
puts "Enviando e-mail para Administrador!!"
spawn telnet 192.168.0.102 25
expect "%"
send "helo script.com.br\r"
expect "%"
send "mail from: [email protected]\r"
expect "%"
send"rcpt to: [email protected]\r"
expect "%"
send "data\r"
expect "%"
send "Backup concluido com sucesso\r"
send "$DATA Tamanho do arquivo de backup: $TAMARQ\r"
send ".\r"
expect "%"
send "quit\r"
expect eof
I tried to use the spawn commands but it does not accept the email, I do not know how to give continuity of it, nor can the data be passed by parameter as I need this script to be scheduled and run alone.