有dockerqingli.sh 文件内容如下:
#!/usr/bin/expect
spawn su root
expect "*password:*"
expect "*密码*"
send "9@Lxc\r"
#expect "登陆成功"
expect eof
expect "]*"
send "docker system prune\r"
expect "*[y/N]*"
send "y\r"
interact
docker system prune直接执行时的结果
[root@localhost lxc347]# docker system prune
WARNING! This will remove:
- all stopped containers
- all networks not used by at least one container
- all dangling images
- all dangling build cache
Are you sure you want to continue? [y/N]
expect dockerqingli.sh运行提示错误:
[li@localhost lxc347]$ expect dockerqingli.sh
spawn su root
密码:
[root@localhost lxc347]# invalid command name "y/N"
while executing
"y/N"
invoked from within
"expect "*[y/N]*""
(file "dockerqingli.sh" line 14)
[li@localhost lxc347]$
dockerqingli.sh 怎么修正文件内容呢?