Pregunta

When I run the following code intereactively from bash it works fine.

cleartool setview $myview
cleartool lsbl

But when I put them in a script and try to run the script, it never returns from the first cleartool command.

It seems in the interactive case the first cleartool command opens a new bash to run in and when you run the second command from the new shell it works fine. But in case of the script the new shell is not being visible and hence it seems not to return from the command.

Is there anyway to keep the cleartool commands in the same bash shell they are running from?

¿Fue útil?

Solución

While it doesn't directly answer the question, the following might do what you want. It makes the second command run in the subshell that the first command opens.

cleartool setview $myview << EOF
cleartool lsbl
EOF

Otros consejos

The cleartool setview command opens a new interactive shell. In that shell you execute the second command when you type it by hand. When you put both lines into a script, the setview executes the shell waiting for your input. The second command is executed as soon as you exit that shell. Of course the second command is not executed in the context of $myview.

To make things a little bit clearer do the following: In a shell execute cleartool setview $myview five times. Type echo $$ after each setview. This gives you the process ID of the current shell. The numbers will increase. Then type exit in each shell. Do echo $$ again after each exit. The old number will appear in decreasing order. After six exits you terminal should be closed.

That was the explanation. A solution for your problem might be the -exec option of the setview command:

cleartool setview $myview -exec "cleartool lsbl"

should do the trick.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top