ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
What is the syntax in C to run a command in the terminal? For example, if I wanted to open the terminal and run a program that puts the line "ifconfig eth1 up" to the terminal...what would the command look like??
I do not want a script, because I want to be able to input more data into the program once information has been fetched from the terminal...am I making sense? I hope so!
You do realise a script and a prog are basically the same thing?
Granted C src is compiled and bash scripts aren't (for example), but they both do the same thing.
Having said that, sounds like you want the system() fn (which btw is actually a lib fn, not a system fn).
You do realise a script and a prog are basically the same thing?
Granted C src is compiled and bash scripts aren't (for example), but they both do the same thing.
Having said that, sounds like you want the system() fn (which btw is actually a lib fn, not a system fn).
It is my understanding that a script cannot be modified while running, while with C, or anyother language, can run, present information, user input, then further processing.
Ok, after some quick googling for syntax I now know that the system function is exactly what I was looking for! Thank you much!!
Last edited by amishmonkey; 09-11-2007 at 09:22 PM.
Reason: "Problem" solved!
To further build on what chrism01 was saying, there really is no difference between scripts and compiled "programs" aside from the obvious matter that scripts are interpreted (at a high-level) and languages like Linux assembly, C and C++ are compiled (interpreted at an extremely low-level).
Both can provide the same functionality, just scripts are a little more pragmatic in some situations due to the fact that they're easier to modify (no need to recompile for every small change) and depending on the use, there may not be that much of an execution speed advantage.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.