scripting with expect

Discussion in 'Getting Started' started by Erik_loa, Jun 19, 2013.

  1. Erik_loa

    Erik_loa New Member

    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    1
    Hello

    I try these lines in a file called hepp.bash

    ------------------------
    #!/usr/bin/expect
    expect "hello"
    ------------------------

    when I do:

    bash hepp.bash

    I get:
    couldn't read file "hello": no such file or directory

    (I have version 5.44.1.15 installed.)

    I guess I am doing some fundamental wrong since I have not been able to find anyone
    having this problem :)

    when I just write expect in the commadn line then the the command line changes to
    expect1.1>

    if I then write expect "hello"
    then it works.


    My question, how do I get expect to work in a script file ?

    BR
    /Erik
  2. Peytonsmith

    Peytonsmith New Member

    Messages:
    16
    Likes Received:
    2
    Trophy Points:
    3
    i would also like to get some helpful responses over the topic just to get an additional;l knowledge about the subject .. have gone to the web for some apt suggestions but didn't find there anything supportive .. now going to my mentor for a help..
  3. eugenyb

    eugenyb New Member

    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    1
    root@host: touch test

    Write this:
    #!/usr/local/bin/expect -f
    send "hello\n"
    #here is my $bin_directory /usr/local/bin/

    then make this file executable:
    chmod +x test.sh
    And then launch it:
    root@host: ./test
    It'll be working fine:

    root@host: ./test
    hello


    It seems to me, you don't now how to use expect scripts :)
    What do you want to do with expect tcl?
    It's quite well to work with TTY and VTY like telnet, ssh command prompts.
    A typical usage of expect is to configure devices with vty/tty interfaces.
  4. ryanvade

    ryanvade Administrator Staff Member Staff Writer

    Messages:
    1,391
    Likes Received:
    454
    Trophy Points:
    83
    If possible, you may want bash and not expect. Just saying.;)

Share This Page