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 |
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.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
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.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
10-09-2002, 10:25 PM
|
#1
|
|
Member
Registered: Jul 2002
Location: Santa Cruz, CA
Distribution: lfs
Posts: 538
Rep:
|
c++ calling bash?
Hi all. I am pretty new to programming as a whole... in my first c++ class and have done a little playing around in bash. My question is this:
I have written a bash script to install a bunch of packages (automated linux from scratch). The code was relatively simple, but the problem I have is that you have to do a "chroot" and "login" a couple of times, which gives you a new bash prompt.... you're not in the program any more. I was wondering if I could write a c++ program which will call the bash scripts (one for each new login) and let me make the program run through w/ out the user needing to call another script.
Is there a way to do this? or would it be better to make it purely c++? if so, how would I use c++ to do system stuff (bash operations)?
I did read that other thread here, but I don't think that it's the same problem I have (if it is, I don't understand it).
Any help would be great. Thank you.
|
|
|
|
10-10-2002, 01:43 PM
|
#2
|
|
Moderator
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,470
Rep: 
|
You can run every system command (with or without parameters) using system function. I don't know if it fits your needs, but you can read more about it when you run
man system.
|
|
|
|
10-11-2002, 04:52 PM
|
#3
|
|
Senior Member
Registered: Nov 2000
Location: Seattle, WA USA
Distribution: Ubuntu @ Home, RHEL @ Work
Posts: 3,892
Rep:
|
Also check out the fork function (man fork) as it will allow you to spawn a process you don't have to wait for... And the exec functions are also sometimes helpful for executing things (man exec).
|
|
|
|
10-12-2002, 09:44 AM
|
#4
|
|
Member
Registered: Sep 2002
Location: Germany
Distribution: SuSE 8.0
Posts: 96
Rep:
|
Do some housekeeping stuff within the bash skript. Modify your skript that it writes a message into a log file before executing a command, which will give you a new prompt. Then, change the file .bashrc to restart your skript, which should now parse the log file and jump to the part where it last time was exited.
I think this will be easier than using c++.
|
|
|
|
10-23-2002, 12:23 PM
|
#5
|
|
Member
Registered: Feb 2002
Location: Jerusalem, Israel
Distribution: Fedora Core 3
Posts: 154
Rep:
|
thanX Azrael sounds like a good idea
I'll try and see what I can up with.
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 03:36 PM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|