cURL / Mailing Lists / curl-library / Single Mail

curl-library

FTP Error 425

From: André Ogrodowski <ogrodowski_at_melag.de>
Date: Mon, 9 Mar 2015 08:12:45 +0000

Hello,

i have a problem with a file-upload over FTP from a Raspberry PI (OS: Paspbian) using libcurl to a Windows 7 PC. If I use Filezilla instead of curl the fileupload is possible.
can somebody help me?
Windows File is disabled.

Thanks for you support.

FTP-Client Code on the Raspberry Pi:

#include <stdio.h>
#include <string.h>

#include <curl/curl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <string.h>
#include <fcntl.h>
#include <errno.h>
#ifdef WIN32
#include <io.h>
#else
#include <unistd.h>
#endif

int main(void)
{
  char filePath[] = "/home/pi/LogFiles/Logfile.txt";
  struct stat fileInfo;
  curl_off_t fsize;
  FILE *fp = NULL;
  CURLcode err;
  struct curl_slist *headerlist=NULL;
  CURL* handle = NULL;

  static const char buf_1 [] = "RNFR "; //UPLOAD_FILE_AS;
  static const char buf_2 [] = "RNTO "; //RENAME_FILE_TO;

  stat(filePath, &fileInfo);

  fsize = fileInfo.st_size;

  fopen(filePath, "r");

  curl_global_init(CURL_GLOBAL_ALL);
  handle = curl_easy_init();

  headerlist = curl_slist_append(headerlist, buf_1);
  headerlist = curl_slist_append(headerlist, buf_2);
  curl_easy_setopt(handle, CURLOPT_POSTQUOTE, headerlist);
  curl_easy_setopt(handle, CURLOPT_VERBOSE, 1L);
  curl_easy_setopt(handle, CURLOPT_UPLOAD, 1L);
  curl_easy_setopt(handle, CURLOPT_FTP_CREATE_MISSING_DIRS, 1L);
  curl_easy_setopt(handle, CURLOPT_PORT, 21L);
  curl_easy_setopt(handle, CURLOPT_URL, "ftp://Nutzer:1234@192.168.70.42/logfile.txt");
  curl_easy_setopt(handle, CURLOPT_INFILESIZE_LARGE, (curl_off_t) fileInfo.st_size);
  curl_easy_setopt(handle, CURLOPT_READDATA, fp);

  err = curl_easy_perform(handle);

  fclose(fp);
  curl_slist_free_all(headerlist);
  curl_easy_cleanup(handle);
  curl_global_cleanup();

  return 0;
}

Logging at Raspberry PI :
* About to connect() to 192.168.70.42 port 21 (#0)
* Trying 192.168.70.42...
* connected
* Connected to 192.168.70.42 (192.168.70.42) port 21 (#0)
* FTP 0xfbe3b8 state change from STOP to WAIT220
< 220 Service ready for new user. (2.1.0.2)
> USER Nutzer
* FTP 0xfbe3b8 state change from WAIT220 to USER
< 331 User name okay, need password.
> PASS 1234
* FTP 0xfbe3b8 state change from USER to PASS
< 230 User logged in, proceed.
> PWD
* FTP 0xfbe3b8 state change from PASS to PWD
< 257 "/" aktuelles Verzeichnis ist das Basis-Verzeichnis (C:\Users\ogrodowski\Desktop\FTP)
* Entry path is '/'
* FTP 0xfbe3b8 state change from PWD to STOP
* protocol connect phase DONE
* DO phase starts
> EPSV
* FTP 0xfbe3b8 state change from STOP to PASV
* Connect data stream passively
< 502 Command not implemented.
* disabling EPSV usage
> PASV
< 227 Entering Passive Mode (192,168,70,42,207,253)
* Trying 192.168.70.42...
* connected
* Connecting to 192.168.70.42 (192.168.70.42) port 53245
* FTP 0xfbe3b8 state change from PASV to STOP
* DO phase is complete
> TYPE I
* FTP 0xfbe3b8 state change from STOP to STOR_TYPE
< 200 Type set to TypeI
> STOR logfile.txt
* FTP 0xfbe3b8 state change from STOR_TYPE to STOR
< 425 Can't open data connection.
* Failed FTP upload: 425
* DO-MORE phase ends with 25
* Remembering we are in dir ""
* Uploaded unaligned file size (0 out of 384 bytes)
* Connection #0 to host 192.168.70.42 left intact
* Upload failed (at start/before it took off)
Segmentation fault

------------------
(program exited with code: 139)
Press return to continue

Freundliche Grüße / Best regards

Andre Ogrodowski
TBTV, Systemtestingenieur / System Test Engineer

MELAG Medizintechnik oHG / MELAG Medical Technology
Geneststraße 6-10
D-10829 Berlin
Tel./phone: +49 30 757911-1066
Fax: +49 30 757911-99
E-Mail: ogrodowski_at_melag.de<mailto:ogrodowski_at_melag.de>
Web: http://www.melag.de<http://www.melag.de/>

[IDS]

MELAG Medizintechnik oHG Sitz Berlin Registergericht AG Charlottenburg HRA 21333 B

Wichtiger Hinweis: Diese Nachricht kann vertrauliche oder nur für einen begrenzten Personenkreis bestimmte Informationen enthalten. Sie ist ausschließlich für denjenigen bestimmt, an den sie gerichtet worden ist. Wenn Sie nicht der Adressat dieser E-Mail sind, dürfen Sie diese nicht kopieren, weiterleiten, weitergeben oder sie ganz oder teilweise in irgendeiner Weise nutzen. Sollten Sie diese E-Mail irrtümlich erhalten haben, so benachrichtigen Sie bitte den Absender, indem Sie auf diese Nachricht antworten. Bitte löschen Sie in diesem Fall diese Nachricht und alle Anhänge, ohne eine Kopie zu behalten.
Important Notice: This message may contain confidential or privileged information. It is intended only for the person it was addressed to. If you are not the intended recipient of this email you may not copy, forward, disclose or otherwise use it or any part of it in any form whatsoever. If you received this email in error please notify the sender by replying and delete this message and any attachments without retaining a copy.

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2015-03-09