The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
.
google unix.com



High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
c function calling from a pearl script jisha Shell Programming and Scripting 2 04-02-2008 05:50 AM
calling one function from another shell script trichyselva UNIX for Dummies Questions & Answers 1 01-17-2008 12:28 AM
Help needed in function calling in a script jisha Shell Programming and Scripting 3 01-15-2008 07:48 AM
urgent calling function from a script jisha Shell Programming and Scripting 2 01-09-2008 02:40 PM
$0 scope in function and calling script beckett Shell Programming and Scripting 16 01-06-2004 11:30 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 06-18-2003
Lebamb Lebamb is offline
Registered User
  
 

Join Date: Jun 2003
Posts: 1
calling c++ function from script

hi,

I just started to work on unix,

I was wondering if it is possible to call a c++ function from a script.
now, i don't mean starting a program, i mean dynamicaly calling a funtion (like working with a dll)

thanks
  #2 (permalink)  
Old 06-18-2003
Perderabo's Avatar
Perderabo Perderabo is offline Forum Staff  
Unix Daemon
  
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,111
Not in general. A few shells like ksh have some features that allow them to extended in this manner. And ksh will dynamically load a shared library if needed. But you can't use just any c++ function. It must be specially written to know how it will be called, what it must return, and what global variables it can use.
  #3 (permalink)  
Old 06-24-2003
google's Avatar
google google is offline Forum Advisor  
Moderator
  
 

Join Date: Jul 2002
Location: Atlanta
Posts: 740
Quote:
Originally posted by Perderabo
A few shells like ksh have some features that allow them to extended in this manner. And ksh will dynamically load a shared library if needed.
Perderabo, Could you elaborate on this? and possibly point me in the direction of a good book with the details? This sounds interesting..
  #4 (permalink)  
Old 06-24-2003
Perderabo's Avatar
Perderabo Perderabo is offline Forum Staff  
Unix Daemon
  
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,111
Information is limited to say the least. I don't know of any book that covers it. And that doesn't surprise me. The details could change with the next release of ksh. There is a Faq on the Kornshell which says:
Quote:
Q4. How do I add built-in commands?
A4. There are two ways to do this. One is write a shared library
with functions whose names are b_xxxx where xxxx is the name of
the builtin. The function b_xxxx takes three argument. The first
two are the same as a mail program. The third parameter is
a pointer argument which will point to the current shell context.
The second way is to write a shared library with a function named
lib_init(). This function will be called with an argument of 0
after the library is loaded. This function can add built-ins
with the sh_addbuiltin() API function. In both cases, the
library is loaded into the shell with the "builtin" utility.
(I'm sure there's a typo in that quote, "mail program" should be "main program".) This is about all that I feel I quote here. In this article, there is an example. But the documentation with the source code had some differences. You really need to download the source code and read the docs that come with it. The file to look at is "builtins.mm" and you can read it with:
nroff -mm < builtins.mm | col -b | more
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 01:22 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0