Graphical Desktop Korn Shell
The familiar “Hello World” Motif application, shown in Listing 1, is actually written in DtKsh instead of C. Similar to C, we initialize the top-level shell widget, then start building the GUI application. Listing 1 shows a standard Motif message dialog using the familiar XmCreateMessageDialog API. In DtKsh, handles to widgets can be retrieved, widgets can be managed and unmanaged, and callbacks can be created. Afterwards, the program enters into the Xt Intrinsic's main loop via XtMainLoop where it processes X protocol events. In this case, clicking on the OK button would be an event processed by the event loop.
The Motif “Hello World” DtKsh application in Listing 1 can be easily ported to C with a few minor changes, shown in Listing 2. By adding some include files, defining some variables, adding some commas and semi-colons, and sprucing up some arguments, we have a C program. The result is that DtKsh shell scripts make the same API calls as the C Motif application.
AIX provides some extra DtKsh help through a GUI builder. Developers can drag and drop widgets onto a canvas, then add logic code to enable the application to do some work. Like any GUI builder, the code is somewhat verbose; however, it is consistent and portable. AIX is the only version of UNIX that offers this feature.
Developers can create their own new APIs for DtKsh by creating glue-layer libraries. Glue-layer libraries enable DtKsh to be extended with built-ins for functions such as system management and networking. The performance advantage of using built-in functions rather than calling to an external command is that built-ins execute within the process of the shell script. Commands that are called externally must create new resources in the operating system and run as separate processes. DtKsh glue layer libraries pass arguments between a normal UNIX C library and the DtKsh shell, and they return a success or failure status. The following list provides a few rules for creating a glue layer:
Name the function with a b_ prefix.
Function returns a 0 integer for success, between 1 and 255 for failure.
Function should take argc and argv as input.
Link your glue-layer libraries shared.
Listing 3 shows a DtKsh shell script that dynamically loads the “example” shared glue-layer library. Once the glue layer library is loaded and the new built-in APIs are defined, the script can make direct calls with arguments to the new built-in functions. In Listing 3, the example built-in is called with the “Hello World” arguments.
By providing in-line built-in functions, we can run scripts much faster because we are not relying on outside programs running as separate system erocesses. Listing 4 shows the C glue-layer for the example built-in shared library. Following the rules outlined above, we prefix the example function with a b_, and we pass in an argument vector and its size. After the function has done its work, we return 0 for success and a positive integer for failure. DtKsh built-in functions can also act as procedures that pass environment variables in and out through its argument list. See Desktop KornShell Graphical Programming by J. Stephen Pendergrast, Jr. [Addison-Wesley, 1995] for more details on how to pass and retrieve environment variables from built-in procedures.
The Desktop Graphical Korn Shell provides programmers with the standard ksh93 baseline APIs with the addition of the X Window System, Motif and the Common Desktop Environment. Shell programmers can write portable shell scripts, prototype GUI shell scripts and migrate GUI shell scripts to faster running C programs. DtKsh also provides programmers with the ability to extend the shell language with built-in shared libraries so that scripts can benefit from feature-rich libraries, such as those for configuration management.
Fast/Flexible Linux OS Recovery
On Demand Now
In this live one-hour webinar, learn how to enhance your existing backup strategies for complete disaster recovery preparedness using Storix System Backup Administrator (SBAdmin), a highly flexible full-system recovery solution for UNIX and Linux systems.
Join Linux Journal's Shawn Powers and David Huffman, President/CEO, Storix, Inc.
Free to Linux Journal readers.Register Now!
- The Italian Army Switches to LibreOffice
- Download "Linux Management with Red Hat Satellite: Measuring Business Impact and ROI"
- Linux Mint 18
- Oracle vs. Google: Round 2
- The FBI and the Mozilla Foundation Lock Horns over Known Security Hole
- Varnish Software's Varnish Massive Storage Engine
- Devuan Beta Release
- Privacy and the New Math
- Ben Rady's Serverless Single Page Apps (The Pragmatic Programmers)
Until recently, IBM’s Power Platform was looked upon as being the system that hosted IBM’s flavor of UNIX and proprietary operating system called IBM i. These servers often are found in medium-size businesses running ERP, CRM and financials for on-premise customers. By enabling the Power platform to run the Linux OS, IBM now has positioned Power to be the platform of choice for those already running Linux that are facing scalability issues, especially customers looking at analytics, big data or cloud computing.
￼Running Linux on IBM’s Power hardware offers some obvious benefits, including improved processing speed and memory bandwidth, inherent security, and simpler deployment and management. But if you look beyond the impressive architecture, you’ll also find an open ecosystem that has given rise to a strong, innovative community, as well as an inventory of system and network management applications that really help leverage the benefits offered by running Linux on Power.Get the Guide