Sponsored Content
Top Forums UNIX for Advanced & Expert Users Writing Custom Builtins for KSH93 Post 302471118 by a_programmer on Friday 12th of November 2010 04:17:42 AM
Old 11-12-2010
Writing Custom Builtins for KSH93

I am looking to create some ksh93 extensions using the custom builtin feature.

I can successfully create a builtin function, load it using the builtin -f command and get an output. However, I want to get/set values of KSH variables from within my built-in.

For example, lets say I am creating builtins to interact with a database. I might create the following builtins:
Code:
sqlopen  - open a db connection/cursor
sqlclose - close a db connection/cursor
sqlfetch - fetch results from a cursor

These can be used in the following fashion:
Code:
sqlopen connection "mydatabase"

sqlopen connection cursor "select first_name, last_name, email from guest"

while sqlfetch cursor first_name last_name email
do
  ## Process the record
done

sqlclose cursor
sqlclose connection

For the above code to work properly, my builtins should be able to read/write the values of the connection, cursor, first_name, last_name and email shell variables.

I have googled around and the documentation on this subject is minimal.
I know we need to use the nval library that is part of the AST package, but am not able to find any sample codes.

Has anyone done anything like this before? A sample code would be awesome! Smilie Any pointers would be appreciated!
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

ksh93 deprecation...

Any means of running ksh93 in a ksh88-mode? Might sound odd, but I want/need to restrict U/Win-developed scripts to correspond to the ksh88 version on my Solaris environment(s). Thanks. (2 Replies)
Discussion started by: curleb
2 Replies

2. Shell Programming and Scripting

ksh88 or ksh93

Hi all! Does anybody know how can I check if any UNIX installation has implemented ksh88 or ksh93? Thanks in advance. Néstor. (3 Replies)
Discussion started by: Nestor
3 Replies

3. Shell Programming and Scripting

program name and function name builtins

Hi Is there a way to get the program/script name or function name usng built ins. Like in many languages arg holds the program name regards (2 Replies)
Discussion started by: xiamin
2 Replies

4. Programming

pthread_mutex_lock in ANSI C vs using Atomic builtins of GCC

I have a program which has 7-8 threads, and lots of shared variables; these variables (and also they may not the primitive type, they may be enum or struct ), then they may read/write by different threads at the same time. Now, my design is like this, typedef unsigned short int UINT16;... (14 Replies)
Discussion started by: sehang
14 Replies

5. Shell Programming and Scripting

Ksh93 vs. Pdksh88: Custom PS1 prompt not working

Greetings! I have to work with a NFS user id between two hosts: A running Ksh 93 and B running pdksh 88. My problem has to do with the custom prompt I created on A: it works like a charm and display colors: PS1="$'\E But I switch over to B, it all goes to hell (private info... (4 Replies)
Discussion started by: alan
4 Replies

6. UNIX for Dummies Questions & Answers

Why does /bin contain binaries for builtins?

Why do shell builtins like echo and pwd have binaries in /bin? When I do which pwd, I get the one in /bin. that means that I am not using the builtin version? What determines which one gets used? Is the which command a definitive way to determine what is being run when I enter pwd? (16 Replies)
Discussion started by: glev2005
16 Replies

7. UNIX for Dummies Questions & Answers

Shell and bash builtins...

Not sure if this is the right forum but I have collated a listing of shell and bash builtins. Builtins is a loose word and may include the '/bin' drawer/folder/directory but NOT any others in the path list. In the case of my Macbook Pro, OSX 10.7.5 the enabled internals is also listed... ... (1 Reply)
Discussion started by: wisecracker
1 Replies

8. UNIX for Advanced & Expert Users

Ksh93 on Linux compatible with ksh93 on AIX

Hi Experts, I have several shell scripts that have been developed on a Linux box for korn ksh93. If we want to run this software on an AIX 6.1 box that runs ksh88 by default can we just change the she-bang line to reference /bin/ksh93 which ships with AIX as its "enhanced shell" to ensure... (6 Replies)
Discussion started by: Keith Turley
6 Replies

9. Programming

Help w/ writing a custom Linux shell using x86 assembly (NASM)

Hello world, I thought this might be a great start to help me with an assignment I have that requires me to write an assembly program that mimics a 32 bit Linux command shell: When launched, your program will perform the following steps in a loop: 1. Print a prompt, specifically “$ “... (1 Reply)
Discussion started by: turtle13
1 Replies

10. AIX

Ksh93/AIX compatibility

Hi everyone ! Im trying to know from wich version of AIX KSH93 is available ? Internet tell me 6.x and 7.x AIX are available, bue what about 5.x ? Is KSH93 available on AIX 5.x ? Is it the same way to manipulate variables as KSH93 on 7.x ? Thanks for your support and have a nice day ! (2 Replies)
Discussion started by: majinfrede
2 Replies
MONGOCOMMANDCURSOR.__CONSTRUCT(3)					 1					 MONGOCOMMANDCURSOR.__CONSTRUCT(3)

MongoCommandCursor::__construct - Create a new command cursor

SYNOPSIS
public MongoCommandCursor::__construct (MongoClient $connection, string $ns, array $command = array()) DESCRIPTION
Generally, you should not have to construct a MongoCommandCursor manually, as there are helper functions such as MongoCollection::aggre- gateCursor and MongoCollection::parallelCollectionScan; however, if the server introduces new commands that can return cursors, this con- structor will be useful in the absence of specific helper methods. You may also consider using MongoCommandCursor::createFromDocument. PARAMETERS
o $connection - Database connection. o $ns - Full name of the database and collection (e.g. "test.foo") o $command - Database command. RETURN VALUES
Returns the new cursor. EXAMPLES
Example #1 MongoCommandCursor example <?php $m = new MongoClient; // Define the aggregation pipeline $pipeline = [ [ '$group' => [ '_id' => '$country_code', 'timezones' => [ '$addToSet' => '$timezone' ] ] ], [ '$sort' => [ '_id' => 1 ] ], ]; // Construct a MongoCommandCursor object $cursor = new MongoCommandCursor( $m, // MongoClient object 'demo.cities', // namespace [ 'aggregate' => 'cities', 'pipeline' => $pipeline, 'cursor' => [ 'batchSize' => 0 ], ] ); foreach($cursor as $result) { } ?> SEE ALSO
MongoCommandCursor.createFromDocument(3), MongoCollection.aggregateCursor(3), MongoCollection.parallelCollectionScan(3). PHP Documentation Group MONGOCOMMANDCURSOR.__CONSTRUCT(3)
All times are GMT -4. The time now is 09:02 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy