# Running multiple commands in a single cleartool session from a script?

##### Question

The cleartool documentation mentions a "Single command mode" and an "Interactive mode". Single command mode lets you run a single command non-interactively. Interactive mode lets you run multiple commands within an interactive session?

I need to run multiple commands from a script using the same session. More specifically, I need to run a cd command to switch to a view directory so I can run find -avobs. I can't use the single command mode, because the working directory is lost between each invocation of cleartool.

Is it possible to write a script to interact using using the interactive mode, or otherwise run multiple commands in the same session from a script?

Note - I have considered running cd from within the batch script, instead of from within cleartool. However, I want to use the syntax cd \\view\<view-tag>, but when I try to run this from cmd.exe, I get an error:

CMD does not support UNC paths as current directories.

And even if I do find a way to solve this without multiple commands in a single session, I'm still interested in whether it is possible in general.

You can use cd in a bash script with cleartool command (Single command mode).

In Windows, a dynamic view would be accessed with

cd m:\MyDynamicView


After that, any cleartool command would be executed in the context of that directory (dynamic view)

Same for a snapshot view.

cd c:\path\to\root\snapshotview


The UNC path is reserved for the view storage (which must be accessible for any client). It is not for the view root directory.

See this answer as an example of cleartool commands used after a cd: they can be used in a script without problem.

Note that you have to start the view first (if it is a dynamic view): see this answer to see a concrete example.