How to make system(command) to runinside a shell script?
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
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.
How to make system(command) to runinside a shell script?
Hi
I am building my applications's UI in Qt 4.4.3. I need to invoke some external shell script on click of a button click . Also i need to invoke "system-config-network" command from the shell script. Earlier i thought of using system("system-config-network") inside shell script but it didnt work out. Please suggest.
If you are using Qt, that implies that you are writing in C. Most languages have something like a "system" call to let you use shell commands. I don't recall how C does this.
However, bear in mind that the C++ domain has nothing to do with the bash domain, and that you MUST abide the correct syntax for each one when you are using it.
The fact that you are calling bash from within a QT program is irrelevant, the bash script needs to abide the bash syntax. And in bash you never do something like "system()", because simply bash doesn't work that way. Bash is a command interpreter by itself, it doesn't need to do a system() call to launch a program, and it can't call a qt or c++ function either.
I assume that "system-config-network" is a command line tool. Isn't it? What does the script do that you can't code in C++ directly? Calling an additional shell instance might be an overkill.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.