Expect/Autoexpect and how to read a text file

Help
Rick62
2006-11-15
2013-05-02
  • Rick62
    Rick62
    2006-11-15

    Hi all,

    I'm using Expect (and Autoexpect as I'm a beginner in the Linux world) with an aim of updating an users' list.
    To automate usual commands (su, useradd, passwd, maildirmake ...), it works. Autoexpect inserts them in series of send/expect.
    I have only one big problem to read a simple text file.
    I have to read the first line as a variable used in all the program.
    In direct command, it works (cat Users.txt>$newUser).
    Using : echo $newUser, I've got the contents of the first line.
    When I write the same sentence in my Expect file using send/expect commands and run it, I get the message :
    can't read "newUser" : no such variable
    while executing
    "send -- "cat Users.txt>$newUser\r"

    who knows where I've made a error ?

    Thanks for your answers.