Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How Can I send the content of a file in Expect? Do I have to use cat command in a way? if yes how? lets say my file is called 1.txt.


expect "Enter command to send:" {send "???? \r"} ???? --> content of the file 1.txt.

share|improve this question
do you want to send the file or receive it? – glenn jackman May 18 '12 at 17:19

expect is just a tcl script app so you can do anything you can do in tcl, such as

send [cat 1.txt]

you can also open the file and read and write its content with tcl.

share|improve this answer
Doesn't work for me with expect version 5.45 on Ubuntu 14.04.2 LTS. I get invalid command name "cat". – Adam Monsen Mar 12 '15 at 18:51

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.