5

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.

example:

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

1
  • do you want to send the file or receive it? May 18, 2012 at 17:19

1 Answer 1

4

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.

2
  • 1
    Doesn't work for me with expect version 5.45 on Ubuntu 14.04.2 LTS. I get invalid command name "cat". Mar 12, 2015 at 18:51
  • 2
    You can use instead: send [exec cat 1.txt]
    – Lilás
    Mar 3, 2017 at 17:38

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .