Attachmate Worldwide  |   Contact Us  |   NetIQ.com
Home » Support » Solution Library

Technical Notes

Verastream Scripting Language OS Call Using PROGRAM BASE
Technical Note 20001
Last Reviewed 10-Aug-2007
Applies To
Verastream Integration Broker version 8.0 or higher
Verastream EAI Suite version 7.1 or higher
Summary

The PROGRAM set of functions is used to temporarily exit the Verastream Universal Integration Engine (UIE) and execute functions at the operating system level. This technical note covers three ways that operating system functions can be executed.

PROGRAM BASE Overview

The PROGRAM set of functions is used to temporarily exit the UIE and execute functions at the operating system level. Operating system functions can be executed in three different ways.

  • PROGRAM – Run external program.
  • PROGRAM_NOWAIT – Run external program without waiting.
  • PROGRAM_SILENT – Run external program without displaying a shell window.

Note: There is also a SHELL BASE statement that opens a command shell on the Microsoft platform; however, this does the same thing as PROGRAM BASE 'cmd'.

Microsoft Example

You can use PROGRAM BASE to execute an application, such as Notepad.

PROGRAM_NOWAIT BASE 'notepad.exe'

In the following example, the Microsoft pause command, which waits for a keystroke, is used to show how the execution of the Verastream application waits until the pause command receives a response. It also shows how the Verastream application will spawn a new process and continue processing if the PROGRAM_NOWAIT is used. In addition, PROGRAM_SILENT is used to show how commands can execute without displaying the shell window.

Sample Code

#===========================================================
#  Demonstrate the uses of:
#
#     PROGRAM -- Run external program
#     PROGRAM_NOWAIT -- Run external program without waiting
#     PROGRAM_SILENT -- Run external program without 
#                       displaying a shell window
#
#  e.g.  PROGRAM BASE '<command>'
#===========================================================

FUNCTION START START
{
    SHOW Dmain
    WAIT BASE
}

#====================================================
#  Displays the shell with pause and waits
#====================================================
FUNCTION PUSHED DmainB1
{
    PROGRAM BASE 'pause'
}

#====================================================
#  Displays the shell with pause and continues
#====================================================
FUNCTION PUSHED DmainB2
{
    PROGRAM_NOWAIT BASE 'pause'
}

#====================================================
#  _SILENT is used for background-type tasks.
#  If pause was executed, we would have a rogue
#  task with no way to respond to the pause
#====================================================
FUNCTION PUSHED DmainB3
{
    PROGRAM_SILENT BASE 'time /T > log.txt'
}

#====================================================
#  You would not want to use this approach for 
#  background-type tasks because it displays the shell
#====================================================
FUNCTION PUSHED DmainB4
{
    PROGRAM BASE 'time /T > log.txt'
}


DIALOG Dmain    ATCOL=100pixels ATLINE=100pixels
 COLS=464pixels LINES=167pixels TITLE='PROGRAM BASE
 Example: MS' FONT=AP_DIALOG FLAT GRIDX=5pixels GRIDY=5pixels
{
    BUTTON DmainB1    X=15pixels Y=20pixels WIDTH=175pixels
 TEXT=PROGRAM FONT=AP_BUTTON 
    BUTTON DmainB2    X=15pixels Y=55pixels WIDTH=175pixels
 TEXT=PROGRAM_NOWAIT FONT=AP_BUTTON    
    BUTTON DmainB3    X=15pixels Y=90pixels WIDTH=175pixels
 TEXT=PROGRAM_SILENT FONT=AP_BUTTON 
    STRING DmainS1    X=220pixels Y=25pixels WIDTH=225pixels
 TEXT='Executes pause command in wait state' FONT=AP_STRING 
    STRING DmainS2    X=220pixels Y=60pixels WIDTH=230pixels
 TEXT='Executes pause command with no wait state'
 FONT=AP_STRING
    STRING DmainS3    X=220pixels Y=95pixels WIDTH=230pixels
 TEXT='Write time to log.txt without showing shell'
 FONT=AP_STRING
    BUTTON DmainB4    X=15pixels Y=125pixels WIDTH=175pixels
 TEXT=PROGRAM FONT=AP_BUTTON
    STRING DmainS4    X=220pixels Y=130pixels WIDTH=240pixels
 TEXT='Write time to log.txt flashing the shell window'
 FONT=AP_STRING
}

UNIX Example

This example demonstrates the different uses of the PROGRAM BASE functions in a UNIX environment. This example will sleep for 5 seconds, and then write an entry to a log file. Use the tail command to watch the log entries. The idea is to notice how the dialog is inactive until the sleep completes when not using NOWAIT. Also, when using NOWAIT, you can watch a new sleep process be added to the process list. Use the following command to watch the log file in a separate shell.

tail -f log.txt

Since the PROGRAM_NOWAIT command returns to the Verastream application to allow more actions, several sleep commands can be executed by clicking the button several times. Use the following command to see the processes.

ps -ef | grep sleep

Sample Code for UNIX

#====================================================
#    This example demonstrates the different uses of 
#    the PROGRAM BASE functions in a Unix environment.
#====================================================
FUNCTION START START
{
    SHOW Dmain
    WAIT BASE
}

#====================================================
#  Displays the shell with pause and waits
#====================================================
FUNCTION PUSHED DmainB1
{
    PROGRAM BASE 'sleep 5'
    PROGRAM_SILENT BASE 'date >> log.txt'
}

#====================================================
#  Displays the shell with pause and continues
#====================================================
FUNCTION PUSHED DmainB2
{
    PROGRAM_NOWAIT BASE 'sleep 5'
    PROGRAM_SILENT BASE 'date >> log.txt'
}

#====================================================
#  _SILENT is used for background-type tasks.
#====================================================
FUNCTION PUSHED DmainB3
{
    PROGRAM_SILENT BASE 'date >> log.txt'
}

DIALOG Dmain    ATCOL=34pixels ATLINE=59pixels
 COLS=470pixels LINES=129pixels TITLE='PROGRAM BASE
 Example: Unix' FONT=AP_DIALOG FLAT GRIDX=5pixels GRIDY=5pixels
{
    BUTTON DmainB1    X=15pixels Y=20pixels WIDTH=140pixels
 TEXT=PROGRAM FONT=AP_BUTTON
    BUTTON DmainB2    X=15pixels Y=55pixels WIDTH=140pixels
 TEXT=PROGRAM_NOWAIT FONT=AP_BUTTON
    BUTTON DmainB3    X=15pixels Y=90pixels WIDTH=140pixels
 TEXT=PROGRAM_SILENT FONT=AP_BUTTON
    STRING DmainS1    X=175pixels Y=25pixels WIDTH=299pixels
 TEXT='Executes sleep 5 in wait state then makes log entry'
 FONT=AP_STRING
    STRING DmainS2    X=175pixels Y=60pixels WIDTH=295pixels
 TEXT='Executes sleep 5 with no wait state and makes log entry'
 FONT=AP_STRING
    STRING DmainS3    X=175pixels Y=95pixels WIDTH=230pixels
 TEXT='Write to log.txt without sleeping' FONT=AP_STRING
}

Related Technical Notes
10999 Verastream Integration Broker Technical Notes

Did this technical note answer your question?

Yes    No    Somewhat     Not sure yet

Additional comments about this tech note:

Need further help? For technical support, please contact Support.