LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   How can I send keystrokes to a terminal program? (http://www.linuxquestions.org/questions/programming-9/how-can-i-send-keystrokes-to-a-terminal-program-921115/)

peter576 12-29-2011 04:10 PM

How can I send keystrokes to a terminal program?
 
Exactly, I'd like to make an ftp connection using the ftp program which can by launch by typing ftp into the terminal. I can write a code in C++ which will connect to the ftp server, but afterwards I should send me keystrokes to the ftp program, not to the terminal itself, if I write system("peter") for example (that's my username) the terminal will write: no such command, after ftp quitted. So I guess I can't use the system function to solve this problem.

Are there any solution to this?

jlinkels 12-29-2011 07:05 PM

expect does exactly that: it spawns a process, and connect stdin and stdout to your terminal.

http://www.tcl.tk/man/expect5.31/

jlinkels

peter576 12-30-2011 05:13 AM

thank you


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