Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!cs.utexas.edu!uunet!melpar!toppin From: toppin@melpar.UUCP (Doug Toppin) Newsgroups: comp.unix.questions Subject: Running 'ftp' from a program using 'popen'? (long) Keywords: ftp popen Message-ID: <205@melpar.UUCP> Date: 9 Oct 90 21:37:23 GMT Distribution: usa Organization: E-Systems, Melpar Division, Falls Church, VA Lines: 35 I am running SCO Xenix 2.2.3 on the 286 with the NRC implementation of TCP/IP (Fusion). I need to transfer some files to another machine in which I cannot port ANY software. I am going to have to transfer the files by having my software run 'ftp' and send the commands to it. I am using 'popen()' to run 'ftp' and am then writing the appropriate command to the file pointer returned by 'popen()'. I am able to get the files to be sent with no problem but I have not been able to read any responses from 'ftp'. If I 'popen' with "rw" 'ftp' doesn't work at all. I have to do the following (with appropriate error checking in my stuff): FILE *fptr; fptr = popen("ftp -n hostname", "w"); /* run ftp (noninteractive option) */ fprintf(fptr, "user login passwd\n"); /* login to remote machine */ fprintf(fptr, "put sourcefile\n"); /* tell ftp to put the file */ pclose(fptr); /* done with ftp */ If I do this the transfer works fine but I cannot get any feedback to my program from 'ftp'. If I redirect 'ftp's output to either a file or a named pipe then only thing I get in either are 3 newlines. If I don't redirect it at all then the correct output appears on my screen. There is no user on this system so I must, under program control, detect a good or bad send. If you have any suggestions or a working example please post it or drop me a line. My system does not have 'rcopy' or any other neat command. 'ftp' is the only thing I have to work with. Please do not suggest using anything other than 'ftp' because we cannot put any software on the destination machine. thanks Doug Toppin uunet!melpar!toppin