1

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.

2 Answers 2

1

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.)

Sign up to request clarification or add additional context in comments.

3 Comments

This does not seem to work, it logs a part of my script and pretty much crashes next.
@Laris: More specifically? What doesn't work? It should execute onetemplate instantiate "mano" --user $CUSER --endpoint $CENDPOINT three times and log the results in screen.log. By the way, what's wrong with onetemplate instantiate ... >> screen.log? I'm curious why you chose script as your logging method.
I tried to use the command > file method, but if i do the command does not work at all, I think it is just a problem with one-tools, but this is the output your part of a script returns prnt.sc/hoi2l2 even if I type my password in, it does not do anything further,
0

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, e. g.

script -c "onetemplate instantiate mano --user xxxxxx --endpoint xxxxxx"

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.