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!
- Server Hardening
- May 2016 Issue of Linux Journal
- EnterpriseDB's EDB Postgres Advanced Server and EDB Postgres Enterprise Manager
- BitTorrent Inc.'s Sync
- The Humble Hacker?
- The Death of RoboVM
- The US Government and Open-Source Software
- Open-Source Project Secretly Funded by CIA
- New Container Image Standard Promises More Portable Apps
- ACI Worldwide's UP Retail Payments
In modern computer systems, privacy and security are mandatory. However, connections from the outside over public networks automatically imply risks. One easily available solution to avoid eavesdroppers’ attempts is SSH. But, its wide adoption during the past 21 years has made it a target for attackers, so hardening your system properly is a must.
Additionally, in highly regulated markets, you must comply with specific operational requirements, proving that you conform to standards and even that you have included new mandatory authentication methods, such as two-factor authentication. In this ebook, I discuss SSH and how to configure and manage it to guarantee that your network is safe, your data is secure and that you comply with relevant regulations.Get the Guide