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 |
i think , but not shure , that it should be done with redirecting standard output and standard input from process
|
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. |
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 |
http://www.advancedlinuxprogramming.com
That all you need to learn how to communicate between process. The tutorial is quite in depth. |
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. |