Results 1 to 2 of 2
Please help me guys ...
hello all ,
i am in the process of learning bash programming,i have a any problem,about call my own C language functions directly or runtime ...
- 01-08-2010 #1Just Joined!
- Join Date
- Dec 2009
- Posts
- 2
runtime C from bash Programing
Please help me guys ...
hello all ,
i am in the process of learning bash programming,i have a any problem,about call my own C language functions directly or runtime from bash shell ??
example : contents main.c...
=========================================
struct {
char function[32] ;
int (*f)(int argc, char *argv[]) ;
} manyfunction[2] =
{
{"functionCalltobash1",functionCalltobash1}
{"functionCalltobash2",functionCalltobash2}
}
=========================================
each functionCalltobash1 and functionCalltobash2 have many other function inside themself.
is bash shell support invoked my C function ??
would you give me a solusion ....
Thanks all...
- 01-08-2010 #2Linux Guru
- Join Date
- Apr 2009
- Location
- I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
- Posts
- 8,974
You cannot directly call to external functions from bash. You would have to wrap those functions in an executable program and access them by running the program with the appropriate options (function to call, arguments, etc). The only exception to this is if you want to write your own versions of bash's builtin shell commands. From the bash man page:
This kind of limits you, I think. In any case, I don't see any way to arbitrarily access your own compiled functions.Code:enable [-adnps] [-f filename] [name ...] Enable and disable builtin shell commands. Disabling a builtin allows a disk command which has the same name as a shell builtin to be executed without specifying a full path- name, even though the shell normally searches for builtins before disk commands. If -n is used, each name is disabled; otherwise, names are enabled. For example, to use the test binary found via the PATH instead of the shell builtin ver- sion, run ‘‘enable -n test’’. The -f option means to load the new builtin command name from shared object filename, on sys- tems that support dynamic loading. The -d option will delete a builtin previously loaded with -f. If no name arguments are given, or if the -p option is supplied, a list of shell builtins is printed. With no other option arguments, the list consists of all enabled shell builtins. If -n is supplied, only disabled builtins are printed. If -a is supplied, the list printed includes all builtins, with an indication of whether or not each is enabled. If -s is supplied, the output is restricted to the POSIX special builtins. The return value is 0 unless a name is not a shell builtin or there is an error loading a new builtin from a shared object.Sometimes, real fast is almost as good as real time.
Just remember, Semper Gumbi - always be flexible!


Reply With Quote