Amol Kahat Amol Kahat - 1 year ago 93
Bash Question

Expect not accepting - value

Hi I try to run expect with - values. But i'm getting bad flag error.

Test File:

echo "Enter Number:"
read num
echo $num

Expect File:

spawn sh
expect -- "Enter Number:" {send "-342345"}

I tried it with \- option still it's not working.

Answer Source

Try this

$ cat
echo "Enter number"
read num
echo $num


$ cat test.exp 
spawn sh
set value "-342345"
expect "Enter number" {
    send -- "$value\r"

Run above command as

$ expect test.exp
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download