Satyam_jay
Satyam_jay

Reputation: 149

How to expect strings with leading '-' char in Expect script

I have tried this code for expecting "-bash-4.3$"

expect "-bash-4.3$"

But it does not work

Upvotes: 1

Views: 821

Answers (2)

pynexj
pynexj

Reputation: 20797

You need to write expect -- -string otherwise expect would think -string is an option.

# expect -c 'expect -bash'
bad flag "-bash": must be -glob, [...], -timeout, -nobrace, or --
    while executing
"expect -bash"
# expect -c 'expect -- -bash'

Upvotes: 3

nitinr708
nitinr708

Reputation: 1467

If it says 'no such file or directory' then you are using it wrong!

You need to define a <testing_expect_script>.exp

and

execute it $ ./<testing_expect_script>.exp

You may use following actions to have your script do something -

  • expect
  • send
  • spawn
  • interact

Upvotes: 1

Related Questions