You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I wrote a client program myself and successfully connected to your FTP server, but failed to create and delete folders on your server. Can you help me find out what went wrong? Grateful.
I am not sure any more, but I think DELE will delete files, while RMD will remove directories. Deleting a non-empty directory will cause a client to open the directory, delete the files inside it and then delete the top-level directory.
Keep in mind, that having directories wasn't thing, when FTP was invented (1972, RFC 354), and thus the first FTP standard didn't support directories!
You can check out the "original" RFC 959 (which still only is an update for that ancient RFC 354). This RFC e.g. adds support for having files in directories. https://tools.ietf.org/html/rfc959 (-> Page 32).
If you really want to implement an FTP Client on your own, I advise you to install an existing client, check what commands it is sending and replicate that behaviour.
I wrote a client program myself and successfully connected to your FTP server, but failed to create and delete folders on your server. Can you help me find out what went wrong? Grateful.
void del(char *usr_cmd) { time_t t_time; t_time=time(NULL); struct tm* tv=localtime(&t_time); char *cmd = strchr(usr_cmd,' '); char filename[1024]; if(cmd == NULL) { printf("command error!\n"); cout<<asctime(tv); return; } else { while(*cmd == ' ') cmd++; } if(cmd == NULL||cmd =="\0") { printf("command error!\n"); asctime(tv); return; } else { strncpy(filename,cmd,strlen(cmd)); filename[strlen(cmd)]='\0'; ftp_send_cmd("DELE ",filename,sock_control); ftp_get_reply(sock_control); } }
int ftp_send_cmd(const char *s1, const char *s2, int sock_fd) { time_t t_time; t_time=time(NULL); struct tm* tv=localtime(&t_time); char send_buf[256]; int send_err, len; if(s1) { strcpy(send_buf,s1); if(s2) { strcat(send_buf, s2); strcat(send_buf,"\r\n"); len = strlen(send_buf); send_err = send(sock_fd, send_buf, len, 0); } else { strcat(send_buf,"\r\n"); len = strlen(send_buf); send_err = send(sock_fd, send_buf, len, 0); } } if(send_err < 0) printf("send() error!\n"); cout<<asctime(tv); return send_err; }
error message:
FTP << DELE stats FTP >> 450 Unable to delete file
The text was updated successfully, but these errors were encountered: