Mit C ein Txt-Dokument auf einen FTP-Server uploaden



  • Hallo,
    Vielen Dank erst mal, das du mir so ausdauernd
    hilfst. Und mir den Code so vorgeschrieben hast.

    Habe das jetzt so ergänzt:

    char *host={"ftp.r0biin93.r0.funpic.de"};
    char *user={"*****"};
    char *password={"*****"};
    char *inputfile={"C:/Users/Robin/Pictures/Desktop/Medien/g5ed2sd2d.txt"};
    char *path={"g5ed2sd2d.txt"};
    netbuf **nControl;
    char mode=FTPLIB_ASCII;
    
    int FtpConnect(const char *host, netbuf **nControl);
    int FtpLogin(const char *user, const char *password, netbuf *nControl);
    int FtpPut(const char *inputfile, const char *path, char mode,
        netbuf *nControl);
    void FtpQuit(netbuf *nControl);
    
    FtpConnect(host, nControl);
    FtpLogin(user, password, *nControl);
    FtpPut(inputfile, path, FTPLIB_ASCII, *nControl);
    FtpQuit(*nControl);
    

    Aber, trotzdem kommt folgender Fehler, weiß aber nicht genau, was er meint.
    Wenn du mir sagen könntest welcher Verwies gemeint ist, vielleicht "*nControl"?, wäre das sehr freundlich.

    char *host={"ftp.r0biin93.r0.funpic.de"};
    char *user={"r0biin93"};
    char *password={"robin1993"};
    char *inputfile={"C:/Users/Robin/Pictures/Desktop/Medien/g5ed2sd2d.txt"};
    char *path={"g5ed2sd2d.txt"};
    netbuf **nControl;
    char mode=FTPLIB_ASCII;

    int FtpConnect(const char *host, netbuf **nControl);
    int FtpLogin(const char *user, const char *password, netbuf *nControl);
    int FtpPut(const char *inputfile, const char *path, char mode,
    netbuf *nControl);
    void FtpQuit(netbuf *nControl);

    FtpConnect(host, nControl);
    FtpLogin(user, password, *nControl);
    FtpPut(inputfile, path, FTPLIB_ASCII, *nControl);
    FtpQuit(*nControl);
    

    Grüße.



  • Hoppala,
    doch glatt das falsche reinkopiert,
    schau nochmal hier das ist der Fehler
    vom Compiler:

    Upload2.o(.text+0x5f):Upload2.c: undefined reference to `FtpConnect'
    Upload2.o(.text+0x7a):Upload2.c: undefined reference to `FtpLogin'
    Upload2.o(.text+0x9d):Upload2.c: undefined reference to `FtpPut'
    Upload2.o(.text+0xaa):Upload2.c: undefined reference to `FtpQuit'
    

    Grüße.



  • Hallo

    Wenn das der komplette code ist, ist es klar, da Funktion nicht lokal deklariert und aufgerufen werden können.

    Aber moment mal, da ist ja ein Zeiger auf nen Zeiger.

    So müsste es gehen:

    char *host={"ftp.r0biin93.r0.funpic.de"};
    char *user={"*****"};
    char *password={"*****"};
    char *inputfile={"C:/Users/Robin/Pictures/Desktop/Medien/g5ed2sd2d.txt"};
    char *path={"g5ed2sd2d.txt"};
    netbuf **nControl;
    char mode=FTPLIB_ASCII;
    
    int FtpConnect(const char *host, netbuf **nControl);
    int FtpLogin(const char *user, const char *password, netbuf *nControl);
    int FtpPut(const char *inputfile, const char *path, char mode,
        netbuf *nControl);
    void FtpQuit(netbuf *nControl);
    
    FtpConnect(host, *nControl);
    FtpLogin(user, password, nControl);
    FtpPut(inputfile, path, FTPLIB_ASCII, nControl);
    FtpQuit(nControl);
    

    Das ist ja nicht der gesamte Code, ne?

    way



  • Der gesamte Code ist dieser:

    #include <stdio.h>
    #include <stdlib.h>
    #include <ftplib.h>
    
    int main(int argc, char *argv[])
    {
    
    //Selbst geschrieben ab hier!    
    char *host={"ftp.r0biin93.r0.funpic.de"};
    char *user={"*****"};
    char *password={"*****"};
    char *inputfile={"C:/Users/Robin/Pictures/Desktop/Medien/g5ed2sd2d.txt"};
    char *path={"g5ed2sd2d.txt"};
    netbuf **nControl;
    char mode=FTPLIB_ASCII;
    
    int FtpConnect(const char *host, netbuf **nControl);
    int FtpLogin(const char *user, const char *password, netbuf *nControl);
    int FtpPut(const char *inputfile, const char *path, char mode,
        netbuf *nControl);
    void FtpQuit(netbuf *nControl);
    
    FtpConnect(host, nControl);
    FtpLogin(user, password, nControl);
    FtpPut(inputfile, path, FTPLIB_ASCII, nControl);
    FtpQuit(nControl);
    
          system("PAUSE");	
    
      return 0;
    }
    


  • Habe es jetzt nocheinmal versucht,
    und wieder folgende Fehlermeldung erhalten:

    [code]
    Upload2.o(.text+0x5f):Upload2.c: undefined reference to FtpConnect' Upload2.o(.text+0x7a):Upload2.c: undefined reference toFtpLogin'
    Upload2.o(.text+0x9d):Upload2.c: undefined reference to FtpPut' Upload2.o(.text+0xaa):Upload2.c: undefined reference toFtpQuit'

    Woran könnte es den noch liegen?
    
    Grüße.
    
    [Diesen Code hab ich verwendet:
    [cpp]
    #include <stdio.h>
    #include <stdlib.h>
    #include <ftplib.h>
    
    int main(int argc, char *argv[])
    {
    
    //Selbst geschrieben ab hier!    
    char *host={"ftp.r0biin93.r0.funpic.de"};
    char *user={"*****"};
    char *password={"*****"};
    char *inputfile={"C:/Users/Robin/Pictures/Desktop/Medien/g5ed2sd2d.txt"};
    char *path={"g5ed2sd2d.txt"};
    netbuf **nControl;
    char mode=FTPLIB_ASCII;
    
    int FtpConnect(const char *host, netbuf **nControl);
    int FtpLogin(const char *user, const char *password, netbuf *nControl);
    int FtpPut(const char *inputfile, const char *path, char mode,
        netbuf *nControl);
    void FtpQuit(netbuf *nControl);
    
    FtpConnect(host, nControl);
    FtpLogin(user, password, *nControl);
    FtpPut(inputfile, path, mode, *nControl);
    FtpQuit(*nControl);
    
          system("PAUSE");	
    
      return 0;
    }
    


  • Hallo

    #include <stdio.h>
    #include <stdlib.h>
    #include <ftplib.h>
    
    int FtpConnect(const char *host, netbuf **nControl);
    int FtpLogin(const char *user, const char *password, netbuf *nControl);
    int FtpPut(const char *inputfile, const char *path, char mode,
    	netbuf *nControl);
    void FtpQuit(netbuf *nControl);
    
    int main(int argc, char *argv[])
    {
    	char *host={"ftp.r0biin93.r0.funpic.de"};
    	char *user={"*****"};
    	char *password={"*****"};
    	char *inputfile={"C:/Users/Robin/Pictures/Desktop/Medien/g5ed2sd2d.txt"};
    	char *path={"g5ed2sd2d.txt"};
    	netbuf **nControl;
    	char mode=FTPLIB_ASCII;
    
    	FtpConnect(host, nControl);
    	FtpLogin(user, password, *nControl);
    	FtpPut(inputfile, path, mode, *nControl);
    	FtpQuit(*nControl);
    
    	std::cin.get();
    }
    

    way



  • Hallo

    Und?

    way



  • Hallo.

    Wenn ich den Code jetzt so einfüge,
    sagt er das in Zeile 26 ( std::cin.get();)
    ein syntax-Fehler vor dem : ist.

    Ich programmiere in C.
    Ich habe die Vermutung, das dies ein Befehl
    aus c++ ist?

    Grüße.



  • Hallo

    Ja, dann mach ein "return 0;" draus (;.

    way



  • Wenn ich ein return 0; draus mache,
    kommt folgender Fehler :

    Upload2.o(.text+0x5f):Upload2.c: undefined reference to `FtpConnect'
    Upload2.o(.text+0x7a):Upload2.c: undefined reference to `FtpLogin'
    Upload2.o(.text+0x9d):Upload2.c: undefined reference to `FtpPut'
    Upload2.o(.text+0xaa):Upload2.c: undefined reference to `FtpQuit'
    

    Grüße.
    😃



  • Hallo

    Hä?

    #include <stdio.h>
    #include <stdlib.h>
    #include <ftplib.h>
    
    int FtpConnect(const char *host, netbuf **nControl);
    int FtpLogin(const char *user, const char *password, netbuf *nControl);
    int FtpPut(const char *inputfile, const char *path, char mode,
        netbuf *nControl);
    void FtpQuit(netbuf *nControl);
    
    int main(void)
    {
        char *host={"ftp.r0biin93.r0.funpic.de"};
        char *user={"*****"};
        char *password={"*****"};
        char *inputfile={"C:/Users/Robin/Pictures/Desktop/Medien/g5ed2sd2d.txt"};
        char *path={"g5ed2sd2d.txt"};
        netbuf **nControl;
        char mode=FTPLIB_ASCII;
    
        FtpConnect(host, nControl);
        FtpLogin(user, password, *nControl);
        FtpPut(inputfile, path, mode, *nControl);
        FtpQuit(*nControl);
    
        return 0;
    }
    

    way



  • Hey.

    Sorry war eben beim Training.

    Also wenn ich deinen Code 1 zu 1 kopiere,
    wird mir das hier:

    Compiler: Default compiler
    Building Makefile: "C:\Users\Robin\Pictures\Desktop\Medien\C . C++\Makefile.win"
    Führt  make... aus
    make.exe -f "C:\Users\Robin\Pictures\Desktop\Medien\C . C++\Makefile.win" all
    gcc.exe -c Upload3.c -o Upload3.o -I"C:/Dev-Cpp/include"   
    
    gcc.exe Upload3.o  -o "Upload3.exe" -L"C:/Dev-Cpp/lib"  
    
    Upload3.o(.text+0x5f):Upload3.c: undefined reference to `FtpConnect'
    Upload3.o(.text+0x7a):Upload3.c: undefined reference to `FtpLogin'
    Upload3.o(.text+0x9d):Upload3.c: undefined reference to `FtpPut'
    Upload3.o(.text+0xaa):Upload3.c: undefined reference to `FtpQuit'
    collect2: ld returned 1 exit status
    
    make.exe: *** [Upload3.exe] Error 1
    

    Als Kompilier-Log angezeigt.
    Frag mich nicht wieso 😉

    ➡ Ich benutze Dev-C++ aber auf C gestellt.

    Grüße.
    Hans Jügen



  • dein complierer findet die lib nicht. musste ihm den pfad eintragen.



  • Hallo

    Moment mal, wenn das doch aus der Lib ist, haben die Funktionsdeklarationen nichts zu suchen.
    Wenn du alles richtig eingebunden hast, müsste er so kompilieren:

    #include <stdio.h>
    #include <stdlib.h>
    #include <ftplib.h>
    
    int main(void)
    {
        char *host={"ftp.r0biin93.r0.funpic.de"};
        char *user={"*****"};
        char *password={"*****"};
        char *inputfile={"C:/Users/Robin/Pictures/Desktop/Medien/g5ed2sd2d.txt"};
        char *path={"g5ed2sd2d.txt"};
        netbuf **nControl;
        char mode=FTPLIB_ASCII;
    
        FtpConnect(host, nControl);
        FtpLogin(user, password, *nControl);
        FtpPut(inputfile, path, mode, *nControl);
        FtpQuit(*nControl);
    
        return 0;
    }
    

    way



  • Wenn ich es so kopiere wie du es hier geschrieben hast,
    spuckt er mir den selben Fehler aus.

    Es kann sein das ich die Lib nicht richtig reingebunden habe,
    da ich sie selbst erst runergeladen habe.

    Was muss ich den beachten?
    Habe die Ftplib.h in den ordner include gepackt
    und fertig.



  • Hallo

    Dann findet er wohl wirklich nicht die lib. Was hast du denn für Files in dem lib-Paket? Sind normalerweise Header, DLL's und eine .lib-Datei dabei. Die müsstest du dann auch dementsprechend i die Ordner packen. Und dann schau mal ob du auch alles, was du in die Ordner gepackt hast, in dein Programm inkludiert.

    Ist schon ne Ewigkeit her das ich was mit Dev-C++ gemacht habe, eventuell ist es also so, dass du wie in Visual Studio die lib extra linken musst. Glaube es zwar nicht aber einen Versuch wäre es allemale Wert.

    way



  • Was für einen Datei Typ muss die Lib den haben?
    Den ich habe gegoogelt und da stand das die Lib
    für DEv-C++ eine *.o Endung haben muss und nicht *.lib.

    eine Ftplib.o - Datei ist in meinem Ordner aber nicht vorhanden,
    also dem Ordner den ich runter geladen habe.

    Grüße.



  • Hallo

    Könnte ich den Link mal sehen?

    way





  • Hallo

    Wenn ich das Standard-Paket runterlade habe ich aber die DLL mit dabei. Die ist wichtig.

    way


Anmelden zum Antworten