Starting the Shell for Programmatic Input

  To invoke the MaxL Shell to take input from the standard output of another program or process, use the -i flag.

For example:

program.sh | essmsh -i

The shell script program.sh may generate MaxL statements as output. The shell script output is piped to essmsh -i, which uses that output as its input. This allows for efficient co-execution of scripts.

Windows Example Using -i Invocation

The following Windows batch script generates a login statement and a MaxL display statement as its output. The -i flag enables that output to be used by essmsh, the MaxL Shell, as input.

echo login admin password on localhost; display privilege user;|essmsh -i

User Admin is logged in, all user privileges are displayed, and the MaxL session is terminated.

UNIX Example Using -i Invocation

The following portion of a shell script ensures that there are no applications on the system by testing whether the display application statement returns zero applications.

if [ $(echo "display application;" | 
essmsh -l admin password -i 2>&1 | 
awk '/Records returned/ {print $7}' ) != "[0]." ]
then
   print "This test requires that there be no applications."
   print "Quitting."
   exit 2
fi

Explanation:

  1. MaxL grammar is piped to a MaxL Shell invocation and login, as the output of the UNIX echo command.

  2. The results of the MaxL session are tested by awk for pattern-matching with the MaxL status message you would get if you entered display application on an empty system: Records returned: [0] .

  3. Awk matches the string 'Records returned: ', and then checks to see if that is equal to '[0].'

  4. If $7 (a variable representing the fifth token awk finds in the status string) is equal to '[0].', there are no applications on the system; otherwise, $7 would equal '[1].' or whatever number of applications exist on the system.

For more information and examples on invocation options, see the Oracle Essbase Technical Reference. Invocation information is also contained in the essmsh “man page”. To view the man page, enter essmsh -h | more at the operating-system command prompt.