Announcement

Collapse
No announcement yet.

ftp files to server

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • ftp files to server

    I'm trying to write code to ftp files to and from an ftp site. I'm able to connect to the server and give it the username and password. The cwd command works as it goes into the /htdocs folder. But when I use the SEND, GET or PUT commands, it says they aren't understood. Here is the code. Any suggestions?

    Thanks, Dave

    FUNCTION PBMAIN()
    ftpHost$ = "localhost" 'you would either use the same localhost or substitute it for an ip address

    TCP OPEN PORT 21 AT "server location" AS #1 'open the command channel to the ftp server
    DO
    TCP Line#1, a$
    MSGBOX a$ 'get the first splurge of data returned
    LOOP UNTIL EOF(1) 'from the ftp server, usually the greeting

    TCP PRINT#1, "user ftp-username"
    TCP Line#1, a$
    MSGBOX a$ '331 Password required for ************

    TCP PRINT#1, "pass password"
    TCP Line#1, a$
    MSGBOX a$ '230 User ******** logged in

    TCP PRINT#1, "cwd /htdocs"
    TCP Line#1, a$
    MSGBOX a$ '250 CWD command successful

    TCP PRINT#1, "get aaaa.txt"
    TCP Line#1, a$
    MSGBOX a$ '500 GET not understood

    TCP PRINT#1, "send bbbb.txt"
    TCP Line#1, a$
    MSGBOX a$ '500 SEND not understood

    TCP CLOSE 1

    END FUNCTION

  • #2
    I've used Don Dickinson FTP code for years

    http://www.greatwebdivide.com/code_tcpip.htm
    BASIC shampoo - DO:LATHER:RINSE:LOOP UNTIL CLEAN <>0

    Comment


    • #3
      Frank Fenti, excellent, works great!

      Comment


      • #4
        I've always created a temporary .BAT file then shelled to it. By including the > (redirect) at the end of each command, you end up with the log of what the screen would have seen and thus can see what did/did not happen. Once the job is donem nuke the .BAT file so that no-one can see the contents.

        Comment


        • #5
          Originally posted by Owen English View Post
          I've always created a temporary .BAT file then shelled to it. By including the > (redirect) at the end of each command, you end up with the log of what the screen would have seen and thus can see what did/did not happen. Once the job is donem nuke the .BAT file so that no-one can see the contents.
          That relies on the Windows FTP client being installed. Something you can't rely on unless you are just writing it for your own use.

          Comment


          • #6
            Originally posted by Stuart McLachlan View Post

            That relies on the Windows FTP client being installed. Something you can't rely on unless you are just writing it for your own use.
            Mmmm, I always thought ftp was in integral function of all versions of Windoze (well XP and on anyway) Stuart. Or is this not the case? Thanks.

            Comment


            • #7
              Originally posted by Owen English View Post

              Mmmm, I always thought ftp was in integral function of all versions of Windoze (well XP and on anyway) Stuart. Or is this not the case? Thanks.
              It's a "Window Feature" that can be turned on or off.via the Control Panel. Not sure what the default is in various Windows versiosn, but I've definitely come across workstations where I had to turn it on before I could use it for internet file transfer using FTP in a batch file.

              Comment

              Working...
              X