connectivity.to.unix.in.ap Article/Article

connectivity.to.unix.in.ap

Command connectivity.to.unix.in.ap Article/Article
Applicable release versions: AP
Category Article (24)
Description integrating Advanced Pick and Unix.

Now that Pick Systems has begun implementing Advanced Pick on various implementations of the Unix Operating System, the most asked question is how to develop applications that can interact between the two environments. Advanced Pick includes several methods to take advantage of the Unix environment including file transfer utilities, several 'C' functions from FlashBASIC or Pick/BASIC and use of all Unix verbs from TCL. This article will focus on the abilities of the file transfer utilities and their use in application development. Future articles will concentrate on the other aspects of the Unix environment. Advanced Pick includes two utilities called IMPORT and EXPORT to move files back and forth between Unix and Pick. To convert a Unix file into the Pick database, use the IMPORT verb to convert the file from Unix file format to Pick. The following example will convert the INITTAB file from Unix into Pick file format and store the item in the master dictionary:

IMPORT MD INITTAB
From: /etc/inittab

The EXPORT facility works in much the same way. The following example will convert the item '12345' from the customer file into Unix file format and store the item in the Unix file /usr/lib/pick/test.item.

EXPORT CUST 12345
To: /usr/lib/pick/test.item

Using these two Pick commands, we can create an application in Unix to transfer files back and forth between the two environments as necessary. The process can be run by a user from the command prompt or as a scheduled job through CRON. To do this, we will need to create a script that can start a Pick process, logon to a particular user and account, execute a macro, proc or basic program and then clean up the process and return to Unix.
Most Advanced Pick/Unix systems are configured as a turn-key system. This means that the inittab file has been configured so that each port will display a Pick logon banner and that the users will never have to deal with Unix. There are two ways to logon to the Pick machine from a port that is configured for Unix. Simply enter ing 'ap' at the command prompt will connect the user to the next available Pick process, assuming that the Pick machine has been started. For our example, this method is not practical as you never know which Pick process you will become. Another way to connect to the Pick virtual machine is to specify the port or process number in the original command line. For example, we could always set aside Pick process 20 as the process used for this script. We would start this process by entering 'ap - 20' at the command prompt. This command to start a Pick process can be expanded to include user and account names to logon, commands to execute at TCL, etc. This is accomplished by stacking data in the command to be executed once the process is activated. Continuing with our example, the following syntax will start a Pick process on line 20, logon as the user DM to the account BA, set the terminal type to an IBM3151 and execute the command 'menu' at TCL:

ap - 20 -d 'rxdmrbarterm ibm3151rmenur'

The '-d' specifies the following string is to be stacked data after the process begins. The entire string must be enclosed in quotes and the meaning of the slash commands are as follows:

r Insert a carriage return.
f Turn echo off. The stacked data will not be displayed.
n Turn echo on. The stacked data will be displayed.
Insert a back slash.
x Exit read. It is used to control the system when stacking commands which empty the input buffer by executing a cancel type ahead commands. Whenever such a command is issued, all data up to the x are deleted. When activating a process for the first time, the system reads one character, then empties the type ahead buffer. Therefore, stacked data should always start by the sequence rx, followed by logon sequence.

The passed data string can include any valid TCL commands including procs, macros and FlashBASIC or Pick/BASIC programs and the passed string is unlimited in size. It is possible for the entire data string to be contained in a Unix file by using the shell command substitution mechanism. For example, the above commands could be placed in the Unix file /usr/lib/pick/logon and used in the following manner:

ap - 20 -d 'cat /usr/lib/pick/logon'

This function could be used to log onto the Pick machine, transfer a file to Unix file format and then execute any Unix command against that file. An example would be if a company had multiple individual stores and wished to send sales information to the computer at the main office. Each evening, the computer at the individual stores could log on a process on the Pick machine, convert the daily sales information into a Unix file and then use any Unix facility to upload the information to the computer at the main office. The facility used to send the information could range from something as simple as modem communications to something as complicated as a network. We could automate this function through the use of the Unix feature CRON, which can schedule jobs to be run at any time ranging from every minute to once a year. The following example would log onto the Pick machine, run a FlashBASIC or Pick/BASIC program called BUILD.SALES and export the resulting file to Unix:

ap -d 'rxdmrsalesrbuild.salesrexport md sales/temp/sales/exit'

To automate this process, please consult your Unix manual on the syntax and usage of the CRON function.
Syntax
Options
Example
Purpose
Related