LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   How to fully control a program within another program (https://www.linuxquestions.org/questions/programming-9/how-to-fully-control-a-program-within-another-program-210524/)

marri 07-28-2004 04:37 AM

How to fully control a program within another program
 
I am working on a program, called A, that should run another program, called B. I'm using "fork() " and "execvp()" together to run the program B. That's all fine but the problem is that the program B is asking for a password after it has been executed. How can program A place a password onto to the stdio, or something, after it has executed the program B in order to keep it running.
Regards

hakiro 07-28-2004 05:22 AM

i think , but not shure , that it should be done with redirecting standard output and standard input from process

bestofmed 07-28-2004 05:27 AM

Try opening the program B stdin (coz almost B expect the password from stdin).

consider using pipes for nicer IPC(InterProcess Communication: look at the popen function manual)

one last note: some programs do a check to look if they are running on terminal or not.

marri 07-28-2004 06:38 AM

thanks, it works fine for me using popen(). But when writing to the pipe, using fprintf(), I am always getting this error/warning when running the program:
stty: standard input: Invalid argument

The program works fine, but I would like to get rid of this message.
regards

melinda_sayang 07-28-2004 10:17 AM

http://www.advancedlinuxprogramming.com

That all you need to learn how to communicate between process. The tutorial is quite in depth.

cracauer 07-28-2004 09:04 PM

The message is printed by the program you call, so you cannot direct supress it (except by supressing the output stream it is printed on which is probably a bad idea).

the correct way to do this would be to create a virtual tty for the child to run in. You can do that directly in C, or you can use `expect` or a similar tty wrapper.


All times are GMT -5. The time now is 02:26 AM.