BASH_Script : Expect


Expect Error: spawn id exp6 not open

  
  
  
  
  1. #/bin/bash 
  2.  
  3. expect << EOF 
  4.  
  5. spawn mail  
  6.  
  7. #set timeout -1  
  8.  
  9. expect { 
  10.         "&" {send "h\r"
  11.         } 
  12.  
  13. expect { 
  14.        "&"    {send "q\r"
  15.        } 

  16. expect eof 
  17. exit 0 
  18.      
  19. EOF 

原因を分析する

  
  
  
  
  1. expect  “&” , eof,
  2. expect: spawn id exp6 not open
  3. spawn , expect  

解決方法:
 

  
  
  
  
  1. 10 -  "&" {send "h\r"}
  2. 10 +  "\&" {send "h\r"}

「」を用いて「&」を記号に解析する
 
補足:

  
  
  
  
  1. #set timeout -1  

expectスクリプトのtimeout失効の設定