Latest LQ Deal: Linux Power User Bundle
Go Back > Forums > Non-*NIX Forums > Programming
User Name
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.


  Search this Thread
Old 03-09-2005, 11:35 AM   #1
Registered: Mar 2004
Location: Valencia, espaņa
Distribution: Slack, Gentoo, Custom
Posts: 162

Rep: Reputation: 30
c++ uses system to give commands to bash

I want to use system (or any method that works to call the following chroot command in bash.

chroot "$LFS" /tools/bin/env -i \ HOME=/root TERM="$TERM" PS1='\u:\w\$ ' \ PATH=/bin:/usr/bin:/sbin:/usr/sbin:/tools/bin \ /tools/bin/bash --login +h
the 'PS1='\u:\w\$ ' ' gave me lots of problems so i exported it as a variable = $PSNEW

i just cant seem to get the syntax right in c++ to pass the command, i tried plenty of variations and the code below is as correct as i've got . .

exitStatus = system("chroot \"$LFS\"" 
" /tools/bin/env -i"
" HOME=/root TERM=\"$TERM\" \"$PSNEW\"" 
" PATH=/bin:/usr/bin:/sbin:/usr/sbin:/tools/bin"
" /tools/bin/bash --login +h");
any ideas please ?
Old 03-09-2005, 03:32 PM   #2
Registered: Sep 2002
Location: Tulsa, OK
Distribution: Slack, baby!
Posts: 349

Rep: Reputation: 33
Whatever your end goal is with this, there has to be a better way than using c++/system.

What, exactly, is your end goal?
Old 03-10-2005, 05:27 AM   #3
Registered: Mar 2004
Location: Valencia, espaņa
Distribution: Slack, Gentoo, Custom
Posts: 162

Original Poster
Rep: Reputation: 30
The end goal is simply to create an automated build of LFS, i think you're right, c++ isn't really suited for this.

I'm gonna go use make, i think it'll do the job a lot better


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
gnome-terminal fails to give bash prompt wfhoney Red Hat 8 04-21-2004 04:38 PM
Help with BASH Commands rridler Linux - Newbie 3 04-16-2004 05:43 PM
Bash commands PhuckFonix Linux - Newbie 2 03-30-2004 08:13 PM
Bash commands wprescott Linux - Distributions 6 04-27-2002 03:56 PM
Is it possible to give MSDOS commands in Unix script??? gopi_20us Programming 1 02-20-2002 01:48 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:38 PM.

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