Amol Kahat Amol Kahat - 5 months ago 16
Linux Question

Expect not accepting negative values

I am trying to run

expect
with negative values. But I'm getting bad flag error.

Test File:

echo "Enter Number:"
read num
echo $num


Expect File:

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


I even tried to escape negative values with
\
option still it's not working.

Answer

You can try this as well

# cat expectscript
#!/usr/bin/expect
spawn sh test.sh
expect "Enter Number:" {send -- "-2394\r"}
expect eof