I wrote this script:
#!/bin/shexpect -c "spawn cu -l /dev/ttyUSB0 -s 115200expect \"foo\"send \"bar\""echo $?And I run it without /dev/ttyUSB0:
$ ls /dev/ttyUSB0ls: cannot access '/dev/ttyUSB0': No such file or directory$ ./test.shspawn cu -l /dev/ttyUSB0 -s 115200cu: open (/dev/ttyUSB0): No such file or directorycu: /dev/ttyUSB0: Line in usesend: spawn id exp4 not open while executing"send "bar""0Why expect returns 0?
How can I detect the spawn failure?