Introduction to OSS
Recap from Introduction to OSS Part 1
Introduction to OSS
OSS File System Basics
Basic Commands and Utilities OSS File Editing
Command Scripting
Running OSS Commands from the Guardian
Environment and Vice Versa
OSH gtacl
Guardian
OSS
Guardian files,
programs,
and objects
OSS files,
programs,
and objects
Invoking TACL Commands from OSS (1 of 2)
The gtacl utility creates a Guardian process from the OSS
shell environment
Uses Guardian process creation API to:
Create a Guardian process with TACL-like options Create a Guardian TACL process that will execute
a single TACL command
Syntax:
$ gtacl -p <program file> [<operand>] $ gtacl -c <operand> [<operand>]
Invoking TACL Commands from OSS (2 of 2)
option -p <program file>
Starts Guardian process from <program file>
Default: Starts TACL process
Can be used with -cpu #, -gpri #, -name /G/name, -debug, … ,options
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 ')
OSS gtacl Utility Examples (1 of 2)
/users/member[62]: gtacl -name /G/mytac -gpri 150 -cpu 0 -p tacl TACL 1> logon member
Password:
Last Logon: 22 MAY 1997, 16:38
TACL (T9205D40 - 12JUL96), Operating System D40, Release D43.02 : :
$DATA MEMBERA 1> status *,term
Process Pri PFR %WT Userid Program file Hometerm
$MYTAC 0,72 150 R 000 230,1 $SYSTEM.SYS77.TACL $ZTNT.#PTY004F $Z10R 3,46 171 001 230,1 $SYSTEM.SYS77.TACL $ZTNT.#PTY004F
$Z11M X 3,288 170 001 230,1 /bin/gtacl $ZTNT.#PTY004F
X 3,292 170 000 230,1 /bin/sh $ZTNT.#PTY004F
3,296 170 001 230,1 $SYSTEM.SYS77.OSH $ZTNT.#PTY004F $DATA MEMBERA 2> EOF!
Are you sure you want to stop this TACL (\SOFTED.$MYTAC)?y /users/member[63]: gtacl -p fup copy taclcstm
?TACL MACRO
== TACL created this file for your protection. 2 RECORDS TRANSFERRED
/users/member[64]: gtacl -p edit "\$data.member.taclcstm;lu a;e" TEXT EDITOR - T9601D20 - (01JUN93)
CURRENT FILE IS $DATA.MEMBER.TACLCSTM ?TACL MACRO
OSS gtacl Utility Examples (2 of 2)
/users/member[66]: gtacl -c time January 31, 2001 19:11:06
/users/member[67]: gtacl -c "status *,term"
Process Pri PFR %WT Userid Program file Hometerm
$Z10Z 3,36 170 R 000 34,100 $SYSTEM.SYS77.TACL $ZTNT.#PTY004F $Z10R 3,46 171 001 34,100 $SYSTEM.SYS77.TACL $ZTNT.#PTY004F
$Z10Y X 3,288 170 001 34,100 /bin/gtacl $ZTNT.#PTY004F
X 3,292 170 000 34,100 /bin/sh $ZTNT.#PTY004F
3,296 170 001 34,100 $SYSTEM.SYS77.OSH $ZTNT.#PTY004F /users/member[68]: gtacl -c 'fileinfo $data.membera.*'
$DATA.MEMBERA
Code EOF Last Modification Owner RWEP PExt SExt
TACLCSTM 101 2048 31JAN2001 10:32:16 34,100 AAAA 8 32 /users/member[69]:
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
Executed by typing in the filename such as:
$ my_script # Executes in subshell
$ . my_script # Executes in current shell
$ ./my_script # When my_script is not in PATH
Comments and Metacharacters
Comments
# This is a comment to let you know what I am doing.
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
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 # Note absence of blanks
$ xyz=" HH” # Quotes needed with embedded blanks
Display with echo statement and use of “$”:
$ echo This is Mr. $me
Removed with the unset command:
$ unset me
No special concatenation operator:
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`
To obtain a listing of defined aliases:
$ alias
To obtain a listing of a specific alias:
$ alias w
Invoked by referring to the name:
$ w
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 esacif 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
test Command Options
General form
test condition or [ condition ]
Some options for condition are:
-a file — # True if file exists
-d file — # True if file exists and is a directory -e file — # True if file exists
-f file — # True if file exists and is a regular file
-n string — # True if the length of string is nonzero -p file — # True if file exists and is a named pipe (FIFO)
-r file — # True if file exists and process has read permission -s file — # True if file exists and has a size > 0
-u file — # True if file exists and its set-user ID bit is set
-w file — # True if file exists and process has write permission -x file — # True if file exists and is executable
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 `
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
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." ;;
Arguments
Arguments are positional and space separated $0 is the name of the script file
$# is the argument count
$n is the nth. argument’s 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
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
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
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
Arithmetic on Shell Variables
x=1 expr 5 + 1 x=$x+1 6 echo $x 1+1 expr 17 * 6 102 x=1 expr $x + 1let 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 + 10) * y" echo $x 64 let (( x = x + 6 )) echo $x 70select 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
select var in word1 word2 … wordn do
command command
… done
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;;
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.
OSS Development
Workstation
HP NonStop Server
OSS Development Environment
Editor (for example, CodeWright)
FTP (for example, FTPC32)
Editor (vi, ed)
C
C++ Compilers
COBOL
Enterprise Toolkit (ETK) Enterprise Plug-in Eclipse
Visual Inspect
Editing Source Files
EDIT files
Type 101, exist only in Guardian name space
ASCII text files
Type 180, exist in OSS and Guardian name space
Guardian programs can access only Guardian files
EDIT/TEDIT editors work on only EDIT files
OSS programs can access OSS and Guardian files
vi and ed editors work only ASCII text files
Conversion programs:
EDITTOC converts EDIT file to ASCII text file CTOEDIT converts ASCII text file to EDIT file
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: pax -r [-cdiknuv] [-f archive] ...
Write: pax -w [-adituvX] [-b blocksize] [-f archive] ... List: pax –f archive
Notes
ustar format is written by default
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
To archive files in sourcedir directory: $ tar -cvf tarfile sourcedir To list archive files in tarfile archive file:
$ tar -tvf tarfile
To extract only .c and .h files from tarfile archive: $ tar -xvf tarfile *.c *.h
Transferring Files to OSS
On the UNIX/Windows workstation:
Create pax file
$ pax -w -v -f src.pax [files . . .] FTP file to OSS environment
$ ftp <OSS host>
> quote oss > cd src
> put src.pax src.pax
On the OSS host:
Change to src directory $ cd src
Extract archive files
Retrieving Files from OSS
On the OSS host:
Create archive file in src directory $ cd src
$ pax -w -v -f paxfile [files . . .]
On the UNIX/Windows workstation:
Get pax file using FTP $ ftp <OSS host>
> quote oss > cd src
> get paxfile paxfile
Read pax file
Native C and C++ Compilers
TNS native C compiler
Accepts K&R C and ISO/ANSI C
TNS native C++ compiler
More powerful than TNS C++ preprocessor
Can use forward declarations of class specializations Can use nested templates
Compiler drivers TNS/R
ccomp, cppcomp for Guardian environment c89 for OSS environment
Compiler drivers TNS/E
nmc, nmcPlus for Guardian environment c89 for OSS environment
Native c89 C Compiler
Accepts C/C++ language source files that comply with
ISO/ANSI C standard.
Is supplied with standard header files and run-time libraries Reads input files using OSS APIs
Use /G syntax to access Guardian files
Supports NonStop extensions
Embedded SQL
Guardian procedure calls
Supports WIDE data model and native memory model
32-bit integers and 32-bit pointers
Native c89 C Compilation System
Components
sqlcfe — Processes embedded NonStop SQL/MP source
statements
cfe — Preprocesses C/C++ source code into binary ucode uopt — Optimizes binary ucode
ugen — Processes binary ucode into binary assembly code as1— Processes binary assembly code into object code
nld — Links object and library files into an executable program sqlcomp — Further processes non-SRL executable file
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
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
Compiling/Linking Flow
prog.c c89 a.out eld eld prog.o ar prog.o lib.a executable prog.L -Wno supp ressc89 Command Options (1 of 2)
-c — Compiles source file and suppresses binding -g — Produces symbolic information for debug
-o — Produces named output file -D — Defines name value
-U — Undefines name value
-E — Expands preprocessor directives without compiling -I — Changes search order for header files
-L — Changes search order for libraries -O — Optimizes executable
c89 Command Options (2 of 2)
-Wnolink — Suppresses linking with nld -Wextensions — Enables NonStop extensions
-Wnld= or –Weld= — Passes arguments to nld/eld utility -Woptimize= — Specifies optimization level 0, 1, or 2
(default is 1)
-Wsystype= — Execution environment, default OSS -Wsqlcomp=[args] — Invokes NonStop SQL/MP compiler,
sqlcomp
-Wrunnamed — Directs nld/eld to set RUNNAMED ON -Wfieldalign — Controls alignment within structures -Winnerlist — Shows generated instructions for each
c89 Command Examples
To compile test.c and produce a.out executable:
$ c89 test.c
To create native SRL, called mylib, in current directory:
$ c89 -Wsrl -Wnld=-ul -o mylib mylib.c
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
To compile a source file having SQL/MP statements,
The make Program
Compatible with the UNIX make program Default make file names
makefile, Makefile, s.makefile, and s.Makefile
make file rules
Default rules kept in /usr/share/mk/posix.mk
Macros typically defined in the UNIX make file
CC = cc
Macros defined in the OSS make file
CC = c89
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
OSS Development Utilities
ar — File archiver, for example:
$ ar tv libc.a
nm — Displays binary file symbolic information, for
example:
$ nm object.o
strip — Removes the symbolic debugging information
and symbol tables from an executable file
strings — Finds printable strings in files
lex — Lexical analyzer program generator yacc — Parser program generator
nld & eld — Native link editor
Creating a Guardian Executable in the OSS
Environment
Use -Wsystype=guardian to generate a Guardian object file Macros predefined:
_TANDEM_SOURCE _GUARDIAN_TARGET
Attributes turned on:
HIGHPIN
HIGHREQUESTER
WIDE model only Example:
$ c89 -Wsystype=guardian -o /G/data/fred/newprog prog.c $ exit
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
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
SQL/MX Processes
MXCI DML Statements OSS Environment DP2 Guardian Environment MXCMP MXRTDSRV DP2Compiling a C/C++ SQL/MX Program (option 1)
SQL/MX C/C++ Source File SQL/MX C/C++ Preprocessor Annotated C/C++Source File SQL/MX object
C/C++ Compiler SQL/MX Compiler eld Linker MyProg.sql mxsqlc MyProg.c or MyProg.cpp /usr/bin/c89 eld MyProg.exe mxCompileUserModule
Compiling a C/C++ SQL/MX Program (option 2)
SQL/MX C/C++ Source File SQL/MX C/C++ Preprocessor Annotated C/C++ Source File SQL/MX Module Definition File C/C++ Compiler SQL/MX CompilerOSS-Hosted SQL/MX C/C++ Preprocessor
Running the preprocessor
mxsqlc myProg.sql -c myProg.cpp -m myProg.m -l myProg.lst mxsqlc source-file [ -c out-file ] [ -m module-definition-file ] [ -l list-file ] [ -p ] [ -t timestamp ] [ -d flag [=value] ]
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
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
c89 -Wsqlmx -Wmxcmp -o sqlprog.exe
sqlprog.ec
$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: $ run -name=/G/<srv-name> <srvobj> Requester: $ run <reqobj>
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]
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>
These conflict with processtype OSS:
set server IN <fname> set server OUT <fname>
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>
NonStop + Open Source
Higher productivity through Unix/linux like
environment.
200+ Open Source ready to run out of the box on
S-series and NonStop Integrity.
Porting time and effort dramatically reduced.
“Runtime” Open Source opening a wide range of
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
Your software is ready to use!
No need to run Configure or make
200+ Open Source on S & NS Series
Vim
nano
Emacs
ed
Editors
Perl
Python
ruby
Languages
Openssl
Openssh
sudo
Gnupg
stunnel
Security
bash
cscope
wget
findutils
Productivity
X11
Samba
vnc
Gvim
LPRng
GUI apps
dmalloc
cvs
floss
make
Dev tools
Apache
Zope
App servers
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++
If you want minimum impact on the OSS behavior, place
/usr/local/bin at the end of the PATH:
export PATH=$PATH:/usr/local/bin
If placing /usr/local/bin at the beginning of the PATH:
export PATH=/usr/local/bin:$PATH
Then Open Source commands will be used instead of
OSS commands (e.g. if you install grep from Floss).
Most Open Source can be installed as a regular user. This
makes sure you won’t alter any existing system
directory or settings.
Open Source man(ual) pages are often delivered in /usr/local/man.
But the OSS man commands also scans other directories by default:
Integration into OSS: Documentation
Default search order: /usr/share/man/manX
/usr/local/man/manX /usr/share/man/catX /usr/local/man/catX
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
Solution: Use MANPATH:
ie: to access only OSS commands documentation:
Permanent: export MANPATH=/usr/share/man Temporary: man –M /usr/share/man <man page>
A possible second issue is that OSS man supports only
ASCII man pages.
/home/roland [2145]: man grep
Nroff/troff is not currently installed, this must be installed in order to use formatted man pages.
To support those formats you can:
Install the OpenSource utility nroff and create a symbolic
link /bin/nroff to point to /usr/local/bin/nroff:
ln -s /usr/local/bin/nroff /bin/nroff
Install OpenSource man:
Package Man_db
(requires: Grep, Groff, Gzip, Less, Sed, Textutils.)
Vim - Vi Improved, an Enhanced vi Editor
Vim is a nearly fully-compatible version of the vi editor.
Features include multi-level undo, syntax highlighting,
command line history, online help, filename
completion, and block operations.
Vim is a major enhancement to the vi editor.
The following screen demonstrates use of the
syntax-aware feature of Vim.
Note the use of color to differentiate the various
syntactical elements of a C program.
Vim - Vi Improved, an Enhanced vi Editor
(cont’d)
NonStop support for best-in-class frameworks
Apache MyFaces
Component based web UI framework
Apache Axis2
Web services framework
Spring
Framework for developing apps using POJO components
Hibernate
Where do SASH frameworks fit?
Mapping SASH to requirements for enterprise Java apps
NonStop SQL/MX
Scalable and available SASH execution container
Presentation Web Services Business logic NSJSP (Tomcat) NonStop TS/MP Persistence Services