LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   runtime C from bash Programing (https://www.linuxquestions.org/questions/programming-9/runtime-c-from-bash-programing-780853/)

is noname 01-08-2010 09:07 AM

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...

MensaWater 01-08-2010 09:21 AM

Bash and other "shells" do "scripting" rather than full programming like C. You can get quite sophisticated with such scripts but they're still interpreted rather than compiled like C.

Bash has no structures, pointers, etc... like C so the above code wouldn't be meaningful.

The Perl scripting language is more efficient when it runs than bash and other shells and looks a little more like what you'd be used to with C but still isn't exactly the same.

Scripting is quite helpful for doing simple repetitive tasks (for loops and the like) without having to bother to compile and I do a fair amount of it so don't want you to get the idea it isn't useful to know. Knowing it is a good idea especially as you're apt to run across scripts shipped by vendors or written by others all the time.

You might want to check out a bash scripting tutorial like the one at:
http://www.linuxconfig.org/Bash_scripting_Tutorial

is noname 01-08-2010 10:21 AM

ok thanks ...


All times are GMT -5. The time now is 05:49 AM.