telnet commands using expect

Hi All,

I am trying to write a expect script to telnet and run a command on a remote host.The command i want to send contains a text value is contained in file.txt in the linux box from where i am running the expect script.I want to pass the contains of file.txt into a variable and call the same variable in the command i want to send to the remote host.
Please help i am unable to do soo..

set timeout -1
send "file=cat /root/scripts/file.txt\r"
spawn telnet 172.XX.XXX.XX
match_max 100000
expect -exact "Trying 172.XX.XXX.XX...\r\r
Connected to 172.XX.XXX.XX (172.XX.XXX.XX).\r\r
Escape character is '^\]'.\r\r
Pragma Systems Inc.\r
Welcome to Pragma TelnetServer\r
(C) Copyright 1994-2005 Pragma Systems, Inc.\r
\r
login name: "
send -- "john\r"
expect -exact "john\r
password: "
send -- "S"
expect -exact "*"
send -- "w"
expect -exact "*"
send -- "o"
expect -exact "*"
send -- "r"
expect -exact "*"
send -- "d"
expect -exact "*"
send -- "@"
expect -exact "*"
send -- "f"
expect -exact "*"
send -- "i"
expect -exact "*"
send -- "s"
expect -exact "*"
send -- "h"
expect -exact "*"
send -- "\r"
expect -exact "\r
Windows NT Domain: "
send -- "\r"
expect -exact "\r
\r
User Account verification is being performed. Please Wait.\r
\r
\r
Terminal Type ?\r
1.) vtxxx\r
2.) ansi\r
3.) wyse 60 and above\r
4.) wyse-50\r
5.) ibm3151\r
\r
Please choose(1-5): "
send -- "\r"
expect -exact "\r
Client reported TERM=xterm\r
[?7h\r
Microsoft Windows \[Version 5.2.3790\]\r
(C) Copyright 1985-2003 Microsoft Corp.\r
\r
c:\\winnt\\profiles\\john>"
send -- "mml iofat:file=$file,nf;\r"
send -- "exit\r"
expect eof

hello
maybe this would help
Automating Tasks with EXPECT