From: anatasluo <[email protected]> 1) One error between P and p configure options. 2) When I run ftpget with option "-g", it transfers a file successfully but exits with code 1. After check the rfc document, I find ftp server will return 150 and then 226.
Signed-off-by: anatasluo <[email protected]> --- toys/net/ftpget.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/toys/net/ftpget.c b/toys/net/ftpget.c index 27ea6db6..1be65cb9 100644 --- a/toys/net/ftpget.c +++ b/toys/net/ftpget.c @@ -20,8 +20,8 @@ config FTPGET transfer, optionally saving under a LOCAL name. Can also send, list, etc. -c Continue partial transfer - -p Use PORT instead of "21" - -P Use PASSWORD instead of "ftpget@" + -P Use PORT instead of "21" + -p Use PASSWORD instead of "ftpget@" -u Use USER instead of "anonymous" -v Verbose @@ -65,7 +65,7 @@ static int xread2line(int fd, char *buf, int len) while (total--) if (buf[total]=='\r' || buf[total]=='\n') buf[total] = 0; else break; - if (toys.optflags & FLAG_v) fprintf(stderr, "%s\n", toybuf); + if (toys.optflags & FLAG_v) fprintf(stderr, "%s\n", buf); return total+1; } @@ -100,19 +100,19 @@ void ftpget_main(void) toys.optflags |= (toys.which->name[3]=='g') ? FLAG_g : FLAG_s; if (!TT.u) TT.u = "anonymous"; - if (!TT.P) TT.P = "ftpget@"; - if (!TT.p) TT.p = "21"; + if (!TT.p) TT.p = "ftpget@"; + if (!TT.P) TT.P = "21"; if (!remote) remote = toys.optargs[1]; // connect - TT.fd = xconnectany(xgetaddrinfo(*toys.optargs, TT.p, 0, SOCK_STREAM, 0, + TT.fd = xconnectany(xgetaddrinfo(*toys.optargs, TT.P, 0, SOCK_STREAM, 0, AI_ADDRCONFIG)); if (getpeername(TT.fd, (void *)&si6, &sl)) perror_exit("getpeername"); // Login ftp_line(0, 0, 220); rc = ftp_line("USER", TT.u, 0); - if (rc == 331) rc = ftp_line("PASS", TT.P, 0); + if (rc == 331) rc = ftp_line("PASS", TT.p, 0); if (rc != 230) error_exit_raw(toybuf); if (toys.optflags & FLAG_m) { @@ -177,9 +177,9 @@ void ftpget_main(void) ftp_line("REST", buf, 350); } else lenl = 0; - ftp_line(cmd, remote, -1); + ftp_line(cmd, remote, 150); lenl += xsendfile(port, ii); - ftp_line(0, 0, (toys.optflags&FLAG_g) ? 226 : 150); + ftp_line(0, 0, 226); } else if (toys.optflags & FLAG_s) { cmd = "STOR"; if (cnt && lenr) { -- 2.25.1 _______________________________________________ Toybox mailing list [email protected] http://lists.landley.net/listinfo.cgi/toybox-landley.net
