thank you very much. All the output can be store in the array but I still meet a small problem. I input ls command, and then print @mylog, but it doesn't contain the result of ls. When I input quit command to quit ftp, and then print @mylog, I get the ls result and quit result together. How can I solve this problem? Thanks a log. By the way, I use to meet this problem when I use C++ and C# to write the same program. In C++ and C#, anonymous pipe is used to implement it and I use multi-thread to solve the problem.