Tandem OSS Training Jan 2810
Tandem OSS Training Jan 2810
Tandem OSS Training Jan 2810
Part 2
2002 hp (524907-001)
Command Scripting
Module 5
Running OSS Commands from the Guardian Environment and Vice Versa
Guardian
OSH
OSS
gtacl
2002 hp (524907-001)
Syntax:
$ gtacl -p <program file> $ gtacl -c <operand> [<operand>] [<operand>]
2002 hp (524907-001)
option -c <operand>
Creates a TACL process that executes a single command and then returns to the OSS shell <operand> is command passed to the TACL process
Might require either double or single quotes (" or ') if string contains spaces or metacharacters (details later)
2002 hp (524907-001)
2002 hp (524907-001)
/users/member[68]: gtacl -c 'fileinfo $data.membera.*' $DATA.MEMBERA TACLCSTM Code 101 EOF 2048 Last Modification 31JAN2001 10:32:16 Owner 34,100 RWEP AAAA PExt 8 SExt 32
/users/member[69]:
2002 hp (524907-001)
Shell Scripts
Shell commands can be stored in ASCII text files (such as command files). Can be programmed like TACL macros. Needs to be secured for execution:
$ chmod $ $ $ u+x my_script # Executes in subshell # Executes in current shell # When my_script is not in PATH
2002 hp (524907-001)
Metacharacters
$ ` \
The slash \ is used to escape the other metacharacters. The semicolon ; is used to separate commands The ampersand & executes a command in the background The braces { } are used for command grouping (for body of a function) The parens () are used to group commands for a subshell or to identify a function (details later)
2002 hp (524907-001)
10
Variables
Name can be any sequence of letters and digits. First character must be a letter. Hyphen - is not allowed. Declaration and initialization:
$ me=Liew $ xyz=" HH # Note absence of blanks # Quotes needed with embedded blanks
11
alias Command
The alias command is a mechanism for defining new commands. Usage examples:
Defined in this manner:
$ alias w=who $ alias duh=`who; date`
2002 hp (524907-001)
Control Structures
These control structures allow conditional testing and looping:
if then fi if then else fi for in do done for do done while do done until do done case in esac
2002 hp (524907-001)
13
if Statement
Test command is used to ascertain TRUE or FALSE TRUE is 0 and FALSE is 1 In place of test, the bracket pair [ ] can be used Examples:
if test 6 = 6 then echo "equal" else echo "not equal" fi # [ ] is short form for test if [ 6 = 6 ] then echo "Same same, both the same" else echo "Not the same" fi
2002 hp (524907-001)
14
15
Loops
for loop
# This script demos use of the for ....do loop. for season in Spring Summer Autumn Winter do echo "Season is " $season done Echo
while loop
# Script to demo while construct and use of expr utility. number=0 while [ "$number" -lt 5 ] do echo "$number" number=`expr $number + 1 ` done echo
2002 hp (524907-001)
16
until Loop
Example:
# Script to demo until construct and use of expr utility. number=0 until [ "$number" -gt 5 ] do echo "$number" number=`expr $number + 1 ` done echo
2002 hp (524907-001)
17
case Structure
Example:
# Script to demo use of case construct. echo "Enter A, B, or C: \c" read letter # More on read command later case "$letter" in a | A) echo "You entered A." ;; b | B) echo "You entered B." ;; c | C) echo "You entered C." ;; * ) echo "Not A or B or C." ;; esac
2002 hp (524907-001)
18
Arguments
Arguments are positional and space separated $0 is the name of the script file $# is the argument count $n is the nth. arguments value $@ is the argument list (like %*% in TACL) $* is also the argument list $$ is PID number of the current process $! is PID number of the most recent background task $? is the exit status of the last executed task or the True or False value from the last execution of the test command
2002 hp (524907-001)
19
Argument Usage
Example:
# Script to demo argument usage. # Usage: <This-file> arg1 arg2 arg3 echo "arg count is: $#" echo "arg list is: $@" for arg in $@ do echo $arg done
2002 hp (524907-001)
20
read Command
Syntax:
read [ -r ] variablename
where -r specifies that the read command treat a \ (backslash) character as just part of the input line, not as a control character.
Reads from standard input Input items are moved to the target variables If there is only one target, then all input items are moved to that target Line continuation is a slash (\), unless the -r flag is used Default item separator is white space IFS (Internal Field Separator) environment variable is used to specify separators
2002 hp (524907-001)
21
Miscellaneous Statements
for, while, or until loops can be interrupted with:
break continue return
break transfers control to the statement after the done statement, terminating execution of the loop continue transfers control to the done statement, which continues execution of the loop return terminates the function or script exit provides a return code to the parent:
Used to terminate a script Non-zero return code represents false, meaning failure Zero return code represents true, meaning success
2002 hp (524907-001)
22
2002 hp (524907-001)
23
let Command
x=5 let x=x+1 echo $x 6 X=5 y=6 let "x = x + 1" "y = y - 2" echo $x $y 6 4
let (( x = x + 6 )) echo $x 70
2002 hp (524907-001)
24
select Command
Useful for continuously displaying a menu to the user Displays each word, preceded by its relative numeric position in list The variable PS3 is displayed as a prompt (default: #?) User keys in a numeric value; var holds corresponding wordi from list Execution stops with break statement or when user enters Control^Y
PS3="Pick one of the above numeric options: " select choice in Add Delete Quit do case "$choice" in Add) echo Acting on Add function;; Delete) echo Acting on Delete function;; Quit) break;; *) echo Wrong choice;; esac done
2002 hp (524907-001)
25
Debugging Scripts
sh -x myscript execute the script and show all the statements that get executed with the variables and wildcards already expanded. check for syntax errors without actually executing the program. sh -n myscript If this returns nothing then your program is free of syntax errors.
2002 hp (524907-001)
26
OSS Development
Module 6
Workstation
Editor (for example, CodeWright) FTP (for example, FTPC32) Editor (vi, ed)
HP NonStop Server
C C++ COBOL
Compilers
Inspect, eInspect
2002 hp (524907-001)
28
Conversion programs:
EDITTOC converts EDIT file to ASCII text file CTOEDIT converts ASCII text file to EDIT file cp /G/vol/subvol/<editfile> <oss path> converts EDIT file to ASCII text file
29
2002 hp (524907-001)
pax Utility
Portable Archive Interchange (pax) utility
POSIX-compliant program Supports ustar and cpio archive formats Reads, writes, and lists members of an archive file Copies directory hierarchies Supports both disk and tape media
Command syntax
Read: List: pax -r [-cdiknuv] [-f archive] ... pax f archive Write: pax -w [-adituvX] [-b blocksize] [-f archive] ...
Notes
ustar format is written by default Standard input/output is assumed if -f flag not provided
2002 hp (524907-001)
30
tar Utility
Useful for file transfers
Packs files into archive file on source machine Extracts files from archive file on destination machine
Examples:
To archive all .c and .h files in current directory:
$ tar -cvf tarfile *.c *.h
2002 hp (524907-001)
31
2002 hp (524907-001)
32
2002 hp (524907-001)
33
34
2002 hp (524907-001)
35
Input to c89
C source files and object files generated by c89 C Libraries of object files produced by the ar utility or by native compilers in either the OSS or Guardian environments
2002 hp (524907-001)
36
Input/Output Files
OSS files
.L Compilation listing .o Object file .a Archive file .srl Shared run-time library (SRL) .c C source file .C C++ source file .cc C++ source file .cpp C++ source file
Guardian files in /G
2002 hp (524907-001)
37
Compiling/Linking Flow
pp re ss no su
prog.L
prog.c
eld
c89
-W
a.out
prog.o
eld
executable
38
2002 hp (524907-001)
39
-Wsqlcomp=[args] Invokes NonStop SQL/MP compiler, sqlcomp -Wrunnamed -Wfieldalign -Winnerlist -Wsuppress
2002 hp (524907-001)
Directs nld/eld to set RUNNAMED ON Controls alignment within structures Shows generated instructions for each statement Default mode, suppresses listing
40
To compile source code modules x.c, y.c, and z.c; bind object files into executable called tst; and produce symbolic information for debugging:
$ c89 -g -o tst x.c y.c z.c
To compile a source file having HP NonStop SQL/MP statements, without sqlcomp phase:
$ c89 srvr.c -Wsql
2002 hp (524907-001)
2002 hp (524907-001)
42
COBOL Compilers
cobol Compiles standard TNS COBOL85 programs nmcobol Compiles G native COBOL85 programs ecobol Compiles H & J native COBOL85 programs Use man utility to find out information about compilation options
2002 hp (524907-001)
43
Removes the symbolic debugging information and symbol tables from an executable file Finds printable strings in files Lexical analyzer program generator Parser program generator Native object file tool
2002 hp (524907-001)
44
2002 hp (524907-001)
45
Debugging a Program
Run program under control of the Inspect debugger
Use Inspect (or native inspect) or Visual Inspect debugger Source-level process debugging
Inspect
$ run -debug program Equivalent to RUND or RUNV program from TACL
eInspect
gtacl p einspect
2002 hp (524907-001)
46
Visual Inspect
Powerful, easy-to-use visual interface Improved data structure handling and COBOL support Better windows management System-level and application-level debugging Support for distributed, multiprocess applications Improved program navigation Support for postmortem debugging
2002 hp (524907-001)
47
SQL/MX Processes
OSS Environment Guardian Environment
MXCI
MXCMP
MXRTDSRV
DML Statements
SQL/MX Database
2002 hp (524907-001)
SQL/MX Catalog
48
mxsqlc
eld Linker
eld
MyProg.c or MyProg.cpp
SQL/MX object
MyProg.exe
MyProg.o
C/C++ object
SQL/MX executable
MyProg.exe
2002 hp (524907-001)
49
C/C++ Compiler
SQL/MX Compiler
C/C++ Executable
2002 hp (524907-001)
mxsqlc [ [ [ [ [ [
2002 hp (524907-001)
51
SQL/MX Compiler (1 of 2)
Installed in $system.system Compiler functions are as follows:
Expands SQL object names by using the current default settings Expands any view definitions Performs type checking for C/C++, NMCOBOL and SQL data types Checks SQL object references to verify their existence Determines an optimized execution plan and access path for each DML statement Generates executable code for the execution plans and creates an SQL module Places the module in the /usr/tandem/sqlmx/USER MODULES subdirectory or embedded in executable file Generates a list of the SQL statements in the program file Returns a completion code
2002 hp (524907-001)
52
SQL/MX Compiler (2 of 2)
Running the SQL/MX compiler for module files
mxcmp -e -v myProg.m
Running the SQL/MX compiler for embedded modules
mxCompileUserModule -e -v myProg.exe
Running the SQL/MX compiler from c89
53
$RECEIVE Handling
Same usage as within Guardian requesters/servers For servers:
Use FILE_OPEN_ to open $RECEIVE Use REPLY[x] to return response
For requesters:
Use FILE_OPEN_ to open server process by name Use WRITEREAD[x] for two-way communication
Usage:
Server: Requester: $ run -name=/G/<srv-name> <srvobj> $ run <reqobj>
Issue: How can requesters and servers be folded into the Pathway environment?
2002 hp (524907-001)
54
Pathway Specifics (1 of 2)
Requester:
Consider using PATHSEND APIs Replace FILE_OPEN_ and WRITEREAD[x] with:
SERVERCLASS_SEND_ SERVERCLASS_SEND_INFO_
Server:
Can still use REPLY[x] Needs PATHWAY configuration update
2002 hp (524907-001)
55
Pathway Specifics (2 of 2)
Server configuration needs:
set server processtype OSS set server cwd <OSS-pathname> set server stdin <fname> set server stdout <fname> set server stderr <fname> set server program <object-pathname>
2002 hp (524907-001)
56
dot1test
/bin/unsupported/dot1test
Allows you to call APIs interactively (OSS version of lispproc). Example:
/home/software/tome: dot1test Welcome to dot1test, version 2.25 30NOV96. *** type "help new" for a list of the latest features & bug fixes in dot1test proc name <exit>: open path <"">: /bin/ls oflag <0x00000002 (O_RDWR)>: O_RDONLY mode:<enter> open() succeeded, returned fildes == 3. proc name <open>:
2002 hp (524907-001)
57
2002 hp (524907-001)
58
Getting started.
Download Open Source from: Connect: http://www.connect-community.org/ Internet: Java, Perl, Php or python based Open Source. ITUG downloads are delivered as file.tar.z .z: You can use winzip, gzip or jar. .tar: use pax or tar utilities in OSS Extract the download under / and read:
/usr/local/Floss/<package>/README_FLOSS
2002 hp (524907-001)
59
Active community
Special Interest Group "Open SIG register at http://www.connect-community.org/ Now regroups Java, OSS and Open Source interests. You can still also use the Tandem Newsgroup:
news:comp.sys.tandem
Remember Open Source is often not supported but you can get help in many various ways (FAQ, Newsgroup, Project page, ). NED/GMCSC supported Open Source:
NonStop XML Parser = Apache Xerces C++ 2.4.0 NonStop Fast XML Parser = Expat 1.95.7 NonStop Soap Client = gSOAP 2.6 NS/JSP = Apache Tomcat LDAP client SDK = Mozilla's Directory SDK 3.0 XSLT Version 2.0 Stylesheet Processor for C++
2002 hp (524907-001)
61
2002 hp (524907-001)
62
So if you install OpenSource grep, man will find the OpenSource grep man page first:
/usr/local/man/man1/grep.1 <-- Open Source grep /usr/share/man/cat1/grep.1 <-- OSS grep
63
2002 hp (524907-001)
64
2002 hp (524907-001)
65
2002 hp (524907-001)
66
2002 hp (524907-001)
67
Spring
Framework for developing apps using POJO components
Hibernate
Object Relational Mapping framework
68
NonStop SQL/MX
Persistence Services
Web Services
Future product plans, dates, and functionality are subject to change without notice
69
70
OSS Manuals
http://docs.hp.com/ Open System Services Installation Guide Open System Services Library Calls Reference Manual Open System Services Management and Operations Guide Open System Services Porting Guide Open System Services Programmers Guide Open System Services Shell and Utilities Reference Manual Open System Services System Calls Reference Manual Open System Services Users Guide
2002 hp (524907-001)
71
2002 hp (524907-001)
72