I need to upload a file using CMD with its FTP commands. But I want to do it using c++ in Visual Studio.
For example if i am doing it by hand these are the steps I take.
1) I open CMD, I enter << ftp hostname.com >>
2) CMD asks for a user name
3) I enter <<username>>
4) CMD asks for a password
5) I enter <<password>>
6) I get logged in
7) I use <<send>> and send my file
8) I log out.
Now I need to write a c++ program in Visual Studio to do all these steps. Now this is my problem
#include<windows.h>
using namespace std;
int main()
{
system(" ftp hostname.com");
// This part is ok, it goes to the site
//Then comes the hard part...
//This is the part where CMD asks for a username and pass
// So I need my program to do the following
//1) Enter my username into CMD
//2) Enter my password into CMD
How do I do this??? How do I get my program to "enter" information into CMD??
The whole point of the program is to upload a file from my computer without using any specific libraries or FTP clients.
You need to use pipes if you really want to use cmd ftp client. However, I highly recommend you to use libcurl instead, it is much more powerful and cross-platform.
Or you could use WinInet or windows sockets directly (however, ftp protocol requires 2 connections opened to the server, it is much more complicated than HTTP).