calling c++ function from script


 
Thread Tools Search this Thread
Top Forums Programming calling c++ function from script
# 1  
Old 06-18-2003
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  
Old 06-18-2003
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  
Old 06-24-2003
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  
Old 06-24-2003
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
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Calling Oracle function from script

Hi I need to call a function in database and update the return value of that function with a value in csv file. test.csv 1,2,3,,5,,,8,9,10 1,2,3,4,5,,,8,9,10 1,2,3,,,,,8,9,10In the above file I want to replace column 2 with a value extracted from database like (select student_id from... (3 Replies)
Discussion started by: kev94
3 Replies

2. Shell Programming and Scripting

Calling function from another bash script

I would like to call functions from another bash script. How can I do it? Some code More code (11 Replies)
Discussion started by: kristinu
11 Replies

3. Shell Programming and Scripting

Calling a function which uses expect from a shells script

Hi all, This is the first time i am using expect. I am trying to call a function with in the shell script. The function will shh to a new server and will pass the password using expect and send. I need help in calling the fuction i am getting follaowing errors... here the script ... (8 Replies)
Discussion started by: firestar
8 Replies

4. Shell Programming and Scripting

SHELL SCRIPT Function Calling Another Function Please Help...

This is my function which is creating three variables based on counter & writing these variable to database by calling another function writeRecord but only one record is getting wrote in DB.... Please advise ASAP...:confused: function InsertFtg { FTGSTR="" echo "Saurabh is GREAT $#" let... (2 Replies)
Discussion started by: omkar.sonawane
2 Replies

5. Shell Programming and Scripting

Calling a C-function froma Perl script

Hi All, How can we call a c function from a perl script? Is it the same way as we do for shell script ? Thanks in advance JS (9 Replies)
Discussion started by: jisha
9 Replies

6. Shell Programming and Scripting

c function calling from a pearl script

Hi, Is it possible to call a c function defined in a .c file from a pearl script? How is this possible? Thannks in advance, JS (2 Replies)
Discussion started by: jisha
2 Replies

7. UNIX for Dummies Questions & Answers

calling one function from another shell script

i have a function defined in one ksh (ksh 1) i want to use that function in another ksh (ksh 2) i am using . $<directoryname>/<ksh name> i am calling the function defined in ksh 1 in ksh 2 i want the returnstatus from the above operation but it is not executing the function what i... (1 Reply)
Discussion started by: trichyselva
1 Replies

8. Shell Programming and Scripting

Help needed in function calling in a script

:confused:Hi , I have a script as shown below: rpttxt() { name="$*" awk '/'"${name}"'/ {print $2 $3"=" $4}' file.txt } xx = rpttxt "COL_HEAD_1" awk 'BEGIN {printf("%36s \n ","'"$xx"'")}' rpttxt() is a function..I want to store the final result of this function in... (3 Replies)
Discussion started by: jisha
3 Replies

9. Shell Programming and Scripting

urgent calling function from a script

Hi, Can we define a function say func1 in a script 1.sh and call this function from another script say 2.sh by passing an argument :confused: (2 Replies)
Discussion started by: jisha
2 Replies

10. Shell Programming and Scripting

$0 scope in function and calling script

Hi folks, I'm just running through an oreilly korn shell book but have witnessed an output difference on my own unix machine and the output provided in the book. Can anyone help? create a script called ascript as follows: function afunc { print in function $0: $1 $2 var1="in... (16 Replies)
Discussion started by: beckett
16 Replies
Login or Register to Ask a Question