Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
passing multiline commands w/ system()
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
gsfgf
Veteran
Veteran


Joined: 08 May 2002
Posts: 1266

PostPosted: Wed Dec 04, 2002 9:08 pm    Post subject: passing multiline commands w/ system() Reply with quote

if i want to call a comamnd like

Code:

              sfdisk /dev/hdc << EOF
              0,407
              ,407
              ;
              ;
              EOF

from the system command in c, how do i do that?
_________________
Aim:gsfgf0
Back to top
View user's profile Send private message
Mandr4ke
Apprentice
Apprentice


Joined: 25 Jul 2002
Posts: 214
Location: Chicago, IL

PostPosted: Fri Dec 06, 2002 11:29 pm    Post subject: Re: passing multiline commands w/ system() Reply with quote

gsfgf wrote:
if i want to call a comamnd like

Code:

              sfdisk /dev/hdc << EOF
              0,407
              ,407
              ;
              ;
              EOF

from the system command in c, how do i do that?


Well this is a bit old,, but try:

char cmd[255] = "sfdisk /dev/hdc << EOF 0,407,407;;EOF";
system(cmd);


maybe.... this will work..
Back to top
View user's profile Send private message
gsfgf
Veteran
Veteran


Joined: 08 May 2002
Posts: 1266

PostPosted: Sat Dec 07, 2002 2:47 am    Post subject: Reply with quote

no go, yo, but thanks
_________________
Aim:gsfgf0
Back to top
View user's profile Send private message
rac
Bodhisattva
Bodhisattva


Joined: 30 May 2002
Posts: 6553
Location: Japanifornia

PostPosted: Sat Dec 07, 2002 8:38 am    Post subject: Reply with quote

I think you want to fork, open a pipe to the child, exec sfdisk in the child, and print the stuff you want to send to it to the pipe in the parent.
_________________
For every higher wall, there is a taller ladder
Back to top
View user's profile Send private message
gsfgf
Veteran
Veteran


Joined: 08 May 2002
Posts: 1266

PostPosted: Sat Dec 07, 2002 3:25 pm    Post subject: Reply with quote

rac wrote:
I think you want to fork, open a pipe to the child, exec sfdisk in the child, and print the stuff you want to send to it to the pipe in the parent.


What's that mean? That was over my head.
_________________
Aim:gsfgf0
Back to top
View user's profile Send private message
rac
Bodhisattva
Bodhisattva


Joined: 30 May 2002
Posts: 6553
Location: Japanifornia

PostPosted: Sat Dec 07, 2002 8:01 pm    Post subject: Reply with quote

I haven't done it in C under Unix in a long time, only Perl, so I didn't feel comfortable writing sample code. There is a description of the process in the perlipc man page under "Using open() for IPC". Also, if you have (or can get to a library that has) W. Richard Stevens' Advanced Programming in the UNIX Environment, chapter 8 on process control and chapter 14 on IPC look like they would be of help to you. BTW, are you the author of cursingcow, or is that a separate project? I read something about this new ncurses installer in the works.
_________________
For every higher wall, there is a taller ladder
Back to top
View user's profile Send private message
gsfgf
Veteran
Veteran


Joined: 08 May 2002
Posts: 1266

PostPosted: Sat Dec 07, 2002 11:18 pm    Post subject: Reply with quote

rac wrote:
BTW, are you the author of cursingcow, or is that a separate project? I read something about this new ncurses installer in the works.


cursingcow is only for PPC as of now and no changes have been made to the cvs code in a couple of months). There is an anaconda installer in the works, but thet's pretty un-gentooish and unnecessary imo.

Also, i've turned away from interface design to functionality for a while. Basically i want to get all featrues (include automated and network) installs setup in interactive text mode and then either myself or someone better at curses can convert the interface to curses.
_________________
Aim:gsfgf0
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum