The JCShell supports the concept of shell scripts. A script file typically contains a sequence of
JCShell commands and must have the extension .jcsh. The JCShell maintains an internal
special variable (${path}) which defines the path in which it searches for script files.
The variable can be set via the /set-var shell command (e.g.
/set-var path c:/JCShellScripts). The JCShell always searches the current directory for
script files. To execute a script, just type the name of the file (without extension)
in the JCShell command line.
The JCShell has a "global" scope for your shell command execution. It executes every script in it's own scope. Variables are relative to the scope. To ensure execution of the script in the same scope as the caller, start the script calling command line with "@"
cm> @myscript
Comment lines in scripts start with a '#' character.
If the JCShell command execution returns an error, the execution of the script will be terminated and the error description will be reported.
Starting the command line with a "-" character allows to continue script execution in case of errors. The JCShell will report the error and continue with the next command in the script.
/mode echo off
/mode trace off
/echo ***************************************
/echo Sample script
/echo
/echo Try to select AID1, AID2
/echo ***************************************
# reset the card and select the applet
/atr
#
aid1=A00000000001
aid2=A00000000002
-/select ${aid1}
if ${response} != '6A82'
# OK, aid1 found, so send it a cmd
/send 000B010200
else
/echo "AID1 not found"
-/select ${aid2}
if ${response} == '6A82'
/echo "AID2 not found"
end
end
Related information