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.
|Speed Up Your Web Site with Varnish||Jun 19, 2013|
|Non-Linux FOSS: libnotify, OS X Style||Jun 18, 2013|
|Containers—Not Virtual Machines—Are the Future Cloud||Jun 17, 2013|
|Lock-Free Multi-Producer Multi-Consumer Queue on Ring Buffer||Jun 12, 2013|
|Weechat, Irssi's Little Brother||Jun 11, 2013|
|One Tail Just Isn't Enough||Jun 07, 2013|
- Speed Up Your Web Site with Varnish
- Containers—Not Virtual Machines—Are the Future Cloud
- Linux Systems Administrator
- Lock-Free Multi-Producer Multi-Consumer Queue on Ring Buffer
- Non-Linux FOSS: libnotify, OS X Style
- Senior Perl Developer
- Technical Support Rep
- UX Designer
- RSS Feeds
- Reply to comment | Linux Journal
3 hours 49 min ago
- Yeah, user namespaces are
5 hours 5 min ago
- Cari Uang
8 hours 37 min ago
- user namespaces
11 hours 30 min ago
11 hours 56 min ago
- One advantage with VMs
14 hours 25 min ago
- about info
14 hours 58 min ago
14 hours 59 min ago
15 hours 6 sec ago
15 hours 2 min ago
Free Webinar: Hadoop
How to Build an Optimal Hadoop Cluster to Store and Maintain Unlimited Amounts of Data Using Microservers
Realizing the promise of Apache® Hadoop® requires the effective deployment of compute, memory, storage and networking to achieve optimal results. With its flexibility and multitude of options, it is easy to over or under provision the server infrastructure, resulting in poor performance and high TCO. Join us for an in depth, technical discussion with industry experts from leading Hadoop and server companies who will provide insights into the key considerations for designing and deploying an optimal Hadoop cluster.
Some of key questions to be discussed are:
- What is the “typical” Hadoop cluster and what should be installed on the different machine types?
- Why should you consider the typical workload patterns when making your hardware decisions?
- Are all microservers created equal for Hadoop deployments?
- How do I plan for expansion if I require more compute, memory, storage or networking?