Find the answer to your Linux question:
Results 1 to 2 of 2
Hi, First, let me explain the issue I am trying to solve. We have a lot of expect scripts with the duplicated send/expect commands. So, I'd like to be able ...
  1. #1
    Just Joined!
    Join Date
    Apr 2008
    Posts
    1

    Calling Expect scripts from other Expect scripts

    Hi,

    First, let me explain the issue I am trying to solve. We have a lot of expect scripts with the duplicated send/expect commands. So, I'd like to be able to extract the duplicated code into the common scripts that can be used by other scripts.

    Below is my test where I am trying to call b.exp from a.exp:

    a.exp
    #!/usr/bin/env expect
    #
    set timeout 5
    spawn $env(SHELL)
    match_max 100000

    send -- "./b.exp $spawn_id\r"

    expect "bla"
    expect eof
    exit

    b.exp
    #!/usr/bin/env expect
    #
    set spawn_id [lrange $argv 0 0]
    send -- "ls -al\r"
    expect bla

    I am passing the spawn_id into the b.exp script and then sending the "ls" command. The "ls" command does not output anything, so I understand that I can't pass just like that the handle to the process from one expect script to the other.

    Could you suggest any other approach to solve my original issue or maybe there's actually a way to talk to the same process from the distinct expect scripts?

    Thanks,
    Seva

  2. #2
    Just Joined!
    Join Date
    Mar 2008
    Posts
    26
    if you want to generate variables from expect script a to expect script b, I'd use another program to generate expect script b, such as awk.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...