McIDAS User's Guide
Version 2012.1

[Search Manual] [Table of Contents] [Go to Previous] [Go to Next]


Running Scripts and Commands Using mcenv

Use the format below for starting a mcenv process.

mcenv -f framespec -e bytes -g number -i numberprog

The table below provides a description of the flags. See the section Configuring McIDAS-X Sessions with .mcidasrc for more information about the -f and -e, -g and -i flags. The -g and -i flags are analogous to the -graphicsColors and -imageColors flags in that section.

Flag Description
-f framespec specifies a set of frames to include in the McIDAS environment (default=one, 480x640 frame)
-e  bytes specifies a memory pool for the frames
-g  number specifies the number of graphics levels (default=8)
-i  number specifies the number of display levels (default=48)
prog specifies a program, script or command to run; see Using Unix Conventions for the correct format to enter McIDAS commands

You can nest mcenv processes. Commands run under a subsequent mcenv do not affect the McIDAS environment created by the initial mcenv.

The examples below show commands and scripts run from mcenv. The dollar signs ($) indicate the Unix prompt and the ampersands (&) indicate the McIDAS environment.

In the example below, the user started a McIDAS environment, logged on to the workstation, and copied an image from one dataset to another, then closed the McIDAS environment.

$ mcenv
& logon.k USER 1234
& imgcopy.k EAST/VIS.1 MYDATA/VIS
& exit 
$ 

In the example below, the user started a McIDAS environment with a 400 line by 500 element frame and ran the mkvisgif script. The second box shows the contents of the mkvisgif script.  

$ mcenv -f 400x500 mkvisgif
#!/bin/sh
# mkvisgif: this script generates GIFs
logon.k USER 1234
imgcopy.k EAST/VIS.1 MYDATA/VIS
imgdisp.k MYDATA/VIS 1
frmsave.k 1 MYPICT.GIF
exit 0

The exit status from a McIDAS command run within a script can be checked by adding the command ret=$? (Bourne or Korn shell) or set ret=$status (C shell) on the line following the McIDAS command. A nonzero exit status usually indicates failure. When that occurs, you can take appropriate action, e.g., run a different McIDAS command or exit the script.

Note for users running under C shell

When you start mcenv, it adds a new .mctmp subdirectory to your MCPATH. If your SHELL environment variable is set to/bin/csh (C shell), mcenv then runs your .cshrc file, if it exists. If MCPATH is set in .cshrc, it overwrites the MCPATH that mcenv just set. Edit your .cshrc file so that it checks to see if your MCPATH is already set. An example of .cshrc file's original MCPATH setting is shown below.

setenv MCPATH $HOME/mcidas/data:$HOME/mcidas/help:~mcidas/data:~mcidas/help

Make the following changes to the MCPATH setting.

if ( ! ${?MCPATH} ) then
     setenv MCPATH $HOME/mcidas/data:$HOME/mcidas/help:~mcidas/data:~mcidas/help
endif

[Search Manual] [Table of Contents] [Go to Previous] [Go to Next]