Previous Topic: Use Remote Interactive ModeNext Topic: Remote Batch Mode


Batch Mode

AutoShell scripts can be invoked from interactive mode, but they are typically run without any manual intervention.

To use batch mode

Invoke AutoShell with the –f switch and the path name of the script to run:

caaipaomautoshell.exe -f hello.js

AutoShell runs the script and terminates when script execution finishes. Interactive mode starts after the script finishes. Specify -i at the end of the command (order matters) to enter interactive mode after processing the script:

caaipaomautoshell.exe -f hello.js -i

Note: In these examples, add –U / -P switches with credentials or set the CAASUSER / CAASPASS environment variables. If credentials are not defined, AutoShell prompts for them before starting script execution.

You can also pass arguments to the script:

caaipaomautoshell.exe -f hello.js 1 abc "x y z"

Passes 1, "abc" and "x y z" to the script. These arguments can be accessed through the arguments array which is a standard JavaScript mechanism.

Specify multiple scripts using multiple occurrences of the –f switch:

caaipaomautoshell.exe -f hello.js -f world.js

The scripts are executed in the order they are specified. When specifying arguments, each script receives its own set of arguments, for example;

caaipaomautoshell.exe -f hello.js 1 -f world.js 2

In this case the hello.js script receives the actual parameter 1 and world.js the parameter 2.

Expression evaluation is another variant. Instead of adding simple expressions to a script and execute them using –f, they can be specified on the command line using the –e switch:

caaipaomautoshell.exe -e Math.sqrt(2)
caaipaomautoshell.exe -e "for(i=1;i<11;i++)qout(i)"