1.执行expect命令的时候一直在报错:
spawn sh setup.sh # invalid command name "Y" while executing "Y" invoked from within "expect "[Y] Yes, I agree. [N] No, I don't agree."",如下图所示:
其中的源码:
/usr/bin/expect <<-EOF
#exp_internal 1 # 开启调试信息
set timeout 1
spawn sh "$WORK_DIR/$unzip_dir/setup.sh"
expect "[Y] Yes, I agree. [N] No, I don't agree.\n"
send "Y\r\n"
解决方案:在[Y]中添加转义字符,修改后的源码如下图所示:
/usr/bin/expect <<-EOF
#exp_internal 1 # 开启调试信息
set timeout 1
spawn sh "$WORK_DIR/$unzip_dir/setup.sh"
expect "\[Y\] Yes, I agree. \[N\] No, I don't agree.\n"
send "Y\r\n"
执行后就不再报错,解决
标签:spawn,invoked,name,No,sh,报错,expect,agree From: https://blog.csdn.net/qq_43861459/article/details/140825020