[英]How to continue execution of a script after using 'script' command
所以我正在编写一个 bash 脚本来创建一些虚拟机,我需要记录我的命令行的输出,所以在某个时候我试图使用script
命令,但它会切断我的脚本,直到我退出命令,有没有办法继续执行我的脚本并记录我的命令行?
该脚本如下所示:
script screen.log
for i in 1 2 3
do
onetemplate instantiate "mano" --user $CUSER --endpoint $CENDPOINT
done
exit
我需要在退出时剪掉它。
只是script
启动一个新的shell。 要让script
运行命令,请使用script -c
command 。 这一切都记录在 手册页中。
您可能想尝试:
export CUSER=...
export CENDPOINT=...
script screen.log <<\EOF
for i in 1 2 3
do
onetemplate instantiate "mano" --user $CUSER --endpoint $CENDPOINT
done
EOF
(需要export
以使变量CUSER
和CENDPOINT
在script
运行的 shell 中可用。)
如果我使用了-c选项,该怎么办,因为如果我像这样使用它
script -c onetemplate instantiate "mano" --user xxxxxx --endpoint xxxxxx
它说--user是无法识别的选项
如果我使用 -c 选项,我会怎么做,因为如果我像这样使用它
script -c onetemplate instantiate "mano" --user xxxxxx --endpoint xxxxxx
它说 --user 是无法识别的选项
你必须引用整个命令,例如
script -c "onetemplate instantiate mano --user xxxxxx --endpoint xxxxxx"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.