so I am writing a bash script to create some VMs and I need to log my command line's output so at a certain point I am trying to use script
command, but it cuts my script off until i exit the command, is there a way to continue execution of my script and log my command line?
The script looks like:
script screen.log
for i in 1 2 3
do
onetemplate instantiate "mano" --user $CUSER --endpoint $CENDPOINT
done
exit
and i need to cut it at exit.
Just script
starts a new shell. To have script
run a command use script -c
command . This is all documented in the manual page .
You may want to try:
export CUSER=...
export CENDPOINT=...
script screen.log <<\EOF
for i in 1 2 3
do
onetemplate instantiate "mano" --user $CUSER --endpoint $CENDPOINT
done
EOF
(The export
is required to make the variables CUSER
and CENDPOINT
available in the shell run by script
.)
What if I used the -c option, how would i do it, because if i use it like
script -c onetemplate instantiate "mano" --user xxxxxx --endpoint xxxxxx
it says that --user is unrecognized option
What if I used the -c option, how would i do it, because if i use it like
script -c onetemplate instantiate "mano" --user xxxxxx --endpoint xxxxxx
it says that --user is unrecognized option
You'd have to quote the entire command, eg
script -c "onetemplate instantiate mano --user xxxxxx --endpoint xxxxxx"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.