LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 01-08-2010, 09:07 AM   #1
is noname
LQ Newbie
 
Registered: Dec 2009
Posts: 11

Rep: Reputation: 0
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...
 
Old 01-08-2010, 09:21 AM   #2
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,831
Blog Entries: 15

Rep: Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669
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
 
Old 01-08-2010, 10:21 AM   #3
is noname
LQ Newbie
 
Registered: Dec 2009
Posts: 11

Original Poster
Rep: Reputation: 0
ok thanks ...
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Menu in bash - Programing User Name. Linux - Newbie 6 12-31-2006 11:03 PM
Port programing in BASH fuzzyash Linux - Software 4 11-16-2006 09:18 AM
bash programing Paxmaster Programming 1 08-23-2005 06:09 PM
Bash programing using 2 variables PcHammer Linux - Software 1 04-21-2004 08:11 AM
Bash programing problem zWaR Programming 3 01-01-2004 05:57 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:35 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration