@runCommand(CMD, [SHOW], [PARAMS], [INITFONTSIZE], [TOOLTIPATTRINCID], [TOOLTIPATTRDECID], [TOOLTIPATTRRESID], [TOOLTIPATTRFITID], [ID], [FILENAMETITLE])

Shows and then runs a Linux command and escapes output results. Font controls are added.

The following parameters are recognized:

CMD

The command to run.

[SHOW]

The command to echo out to user (optional).

[PARAMS]

Specific set of configuration parameters to pass to the FontControl(node, param) contstructor. This needs to be in the form of a JavaScript structure. If this parameter is specified, NONE of the other control parameters are honored.

[INITFONTSIZE]

This optional setting allows one to control the initial font-size of the command results. This is a CSS size.

[TOOLTIPATTRINCID]

This optional setting allows one to override the ID of the tooltip for the increase font-size button.

[TOOLTIPATTRDECID]

This optional setting allows one to override the ID of the tooltip for the decrease font-size button.

[TOOLTIPATTRRESID]

This optional setting allows one to override the ID of the tooltip for the restore font-size button.

[TOOLTIPATTRFITID]

This optional setting allows one to override the ID of the tooltip for the fit height button.

[ID]

This optional setting is intended for functions which generated run command output at run time (as opposed to compilation time). If you include this parameter - make sure it is a unique ID).

[FILENAMETITLE]

File name and PDF title for this run command (optional).

It should be noted that this macro will collect BOTH standard out and standard error and pipe the results through html_escape (this allows the results to be shown to the user via a web browser. NOTE: You typically omit the second option - it is only required if you want to echo out a '$' symbol (like using a for loop variable). A font-size control will be place just above the ouput in the upper right-hand corner.

Example of using the macro:

<!-- Using standard default button controls. -->
@runCommand("ls -al /etc")

<!-- Tweaking just a couple of parameters. -->
@runCommand("ls -al /etc",,"{
  fontSizeInit: '12pt',
  noFitButton: true
}")

<!-- Adjusting of the controls (at the time of this writing). -->
@runCommand("ls -al /etc",,"{
  ttIncId: 'myRunInc',
  ttDecId: 'myRunDec',
  ttResId: 'myResId',
  ttFitId: 'myFitId',
  
  fontSizeInit: '12pt',
  fontSizeInc: 20,
  fontSizeDec: 20,
  fontSizeMax: 1000,

  initMode: 'fit',
  noFitButton: false,
  fitDecorHeight: 24,
  fitDecorWidth: 50,
  scrollBottom: true,

  buttonRightOfs: 200
}")

Assuming the com.ccg.macros.at.All class is within your CLASSPATH and the config/bash.at macros file has been generated (Hint: run make atmacros in the wui directory), a developer should be able to run the above example by copy/pasting from below:

[root@probe root]# java com.ccg.macros.at.All <<EOF
@include("config/bash.at",,"d")

<!-- Using standard default button controls. -->
@runCommand("ls -al /etc")

<!-- Tweaking just a couple of parameters. -->
@runCommand("ls -al /etc",,"{
  fontSizeInit: '12pt',
  noFitButton: true
}")

<!-- Adjusting of the controls (at the time of this writing). -->
@runCommand("ls -al /etc",,"{
  ttIncId: 'myRunInc',
  ttDecId: 'myRunDec',
  ttResId: 'myResId',
  ttFitId: 'myFitId',
  
  fontSizeInit: '12pt',
  fontSizeInc: 20,
  fontSizeDec: 20,
  fontSizeMax: 1000,

  initMode: 'fit',
  noFitButton: false,
  fitDecorHeight: 24,
  fitDecorWidth: 50,
  scrollBottom: true,

  buttonRightOfs: 200
}")


EOF

This macro is defined as:

@define("run_cmd_cnt","0","ifnew")@increment("run_cmd_cnt")
<pre@htmlAttr("id","@ifEqual("@param(8)",,"run_cmd_id_@run_cmd_cnt()","@param(8)")")
@htmlAttr("class","screen")>
[${USER:-apache}@${HOSTNAME:-probe}]\\$ @bold("@htmlEscape("@fnb("@param(1)","@param(0)")")")
$(@param(0) 2>&1 | html_escape)</pre>
@javascriptBegin()
// Enhance the screen entity above
new FontControl(document.getElementById("@ifEqual("@param(8)",,"run_cmd_id_@run_cmd_cnt()","@param(8)")"), @ifEqual("@param(2)",,"{
  buttons: FontControl.ALL_BUTTONS | FontControl.VIEW_BUTTON | FontControl.DOWNLOAD_BUTTON | FontControl.COPY_CONTENTS_BUTTON,
  fileNamePrefix: @ifEqual("@param(9)","","'command'","'@param(9)'"),
  placeHolder: false@ifEqual("@param(3)",,,",
    fontSizeInit: @param(3)")@ifEqual("@param(4)",,,",
    ttIncId: @param(4)")@ifEqual("@param(5)",,,",
    ttDecId: @param(5)")@ifEqual("@param(6)",,,",
    ttResId: @param(6)")@ifEqual("@param(7)",,,",
    ttFitId: @param(7)")
}","@param(2)"));
@javascriptEnd()