Results 1 to 18 of 18

Thread: FTP DOS Commands

  1. #1

    Thread Starter
    Fanatic Member TheVader's Avatar
    Join Date
    Oct 2002
    Location
    Rotterdam, the Netherlands
    Posts
    871

    FTP DOS Commands

    Hi everybody,

    I'm trying to use DOS commands to perform FTP actions. I simply make a BAT file and run it with VB. This works with all actions as far as I have tested, but not with FTP functions...

    It only seems to be executing the first line...
    This the the BAT file (user name and password are correct):
    Code:
    ftp garegozers.net
    user gg-thevader ******
    dir
    Can anyone help me with this...?
    Last edited by TheVader; Dec 10th, 2003 at 02:27 PM.
    Author for Visual Basic Web Magazine

    My articles on the Web Browser Control:
    Using the Web Browser Control & Using the DHTML Document Object Model

    The examples referenced in the articles can be found here:

  2. #2
    Frenzied Member Shawn N's Avatar
    Join Date
    Dec 2001
    Location
    Houston
    Posts
    1,631
    You do realize you've left your password there right?
    Please rate my post.

  3. #3

    Thread Starter
    Fanatic Member TheVader's Avatar
    Join Date
    Oct 2002
    Location
    Rotterdam, the Netherlands
    Posts
    871
    Originally posted by Shawn N
    You do realize you've left your password there right?
    Yes, I do, thanks. And I don't mind anyone visiting, there's only crap on that server anyway.

    (and '******' isn't my usual password anyway )
    Last edited by TheVader; Dec 10th, 2003 at 02:28 PM.
    Author for Visual Basic Web Magazine

    My articles on the Web Browser Control:
    Using the Web Browser Control & Using the DHTML Document Object Model

    The examples referenced in the articles can be found here:

  4. #4
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649
    What the bat file is doing is starting a FTP session and then waits for that to finish before going to line 2.

    What you want todo is to send the FTP commands to the FTP prompt and not to Windows command prompt. Save all FTP commands to a text file and use this in your BAT file:
    VB Code:
    1. FTP -s:c:\thePath\theNameOfTheTextFile.txt

  5. #5
    Fanatic Member
    Join Date
    Sep 2000
    Posts
    770
    There's this nifty built in feature called the help switch....

    FTP /?

    It SHOULD tell you the commands available and how to use them.

    I'm sure the msdn.microsoft.com site has helpfull info.

    Search engines.. Gota love e'm.

  6. #6

    Thread Starter
    Fanatic Member TheVader's Avatar
    Join Date
    Oct 2002
    Location
    Rotterdam, the Netherlands
    Posts
    871

    Thumbs up

    Thanks a lot, Joachim.
    Author for Visual Basic Web Magazine

    My articles on the Web Browser Control:
    Using the Web Browser Control & Using the DHTML Document Object Model

    The examples referenced in the articles can be found here:

  7. #7
    Banned Kyle_Katarn's Avatar
    Join Date
    Jul 2002
    Location
    Toulouse, France
    Posts
    89
    You should use K-FTP instead.
    ( http://www.katarncorp.com/?kftp )

    Kyle

  8. #8

    Thread Starter
    Fanatic Member TheVader's Avatar
    Join Date
    Oct 2002
    Location
    Rotterdam, the Netherlands
    Posts
    871
    Is there any way I can keep an FTP session active with the CMD? So e.g. first I log on to the server with a BAT and TXT file, then later on I want to change the directory, or download a file or something like that. But since you can't add commands 'on the fly' I can't figure out how to do that.

    Thanks for any help.
    Author for Visual Basic Web Magazine

    My articles on the Web Browser Control:
    Using the Web Browser Control & Using the DHTML Document Object Model

    The examples referenced in the articles can be found here:

  9. #9
    Frenzied Member ober0330's Avatar
    Join Date
    Dec 2001
    Location
    OH, USA
    Posts
    1,945
    Originally posted by Kyle_Katarn
    You should use K-FTP instead.
    ( http://www.katarncorp.com/?kftp )

    Kyle
    STOP SPAMMING.
    format your code!! - [vbcode] [/vbcode]

    ANSWERS CAN BE FOUND HERE!!

    my personal company

  10. #10
    Banned Kyle_Katarn's Avatar
    Join Date
    Jul 2002
    Location
    Toulouse, France
    Posts
    89
    Ain't spamming. Just giving solutions.

  11. #11
    Frenzied Member ober0330's Avatar
    Join Date
    Dec 2001
    Location
    OH, USA
    Posts
    1,945
    That is not a solution. That is an advertisement for your software. The user is trying to write their own software, not use something that has already been made.

    Again I say, stop spamming or I'll report you. I'm not the only person that has warned you about this.
    format your code!! - [vbcode] [/vbcode]

    ANSWERS CAN BE FOUND HERE!!

    my personal company

  12. #12
    Banned Kyle_Katarn's Avatar
    Join Date
    Jul 2002
    Location
    Toulouse, France
    Posts
    89
    Ok...

  13. #13
    Addicted Member Para80d's Avatar
    Join Date
    Oct 2003
    Location
    Denton, TX
    Posts
    160
    i don't think any page with a "Buy Now" Button would qualify as a solution to an answer. Considering your avatar is the same as the company's logo.

    C++/VB6&.NET/QBasic/HTML/PHP/MySQL/SQLServer2k

    I'm the guy your little brother looks a lot alike. Tell your mom i said thanks.

    naked in vegas

  14. #14
    Frenzied Member ober0330's Avatar
    Join Date
    Dec 2001
    Location
    OH, USA
    Posts
    1,945
    Giving someone a shareware OCX is not the same as answering someone's question or responding with how someone could attack a problem.
    format your code!! - [vbcode] [/vbcode]

    ANSWERS CAN BE FOUND HERE!!

    my personal company

  15. #15
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649
    Originally posted by TheVader
    Is there any way I can keep an FTP session active with the CMD? So e.g. first I log on to the server with a BAT and TXT file, then later on I want to change the directory, or download a file or something like that. But since you can't add commands 'on the fly' I can't figure out how to do that.

    Thanks for any help.
    It sounds to me as if you want to build a GUI for a FTP client. In that case you shouldn't shell out to FTP.exe. Instead you could go with the INet control but that isn't very good especially if the server doesn't have a Windows label on it

    I wrote an article a couple of years ago on how to use API functions that comes with IE for FTP. The article and a couple of VB classes is published at VB2theMax.

    Cheers,

  16. #16

    Thread Starter
    Fanatic Member TheVader's Avatar
    Join Date
    Oct 2002
    Location
    Rotterdam, the Netherlands
    Posts
    871
    Thanks, I'll check out the article. Yeah, i'm using FTP in my app; I'm now using the Inet Control, but it's annoyingly limited and the Winsock control is very difficult to master; so I thought this would be an easy solution...
    Author for Visual Basic Web Magazine

    My articles on the Web Browser Control:
    Using the Web Browser Control & Using the DHTML Document Object Model

    The examples referenced in the articles can be found here:

  17. #17
    Fanatic Member MikkyThomeon's Avatar
    Join Date
    Oct 2002
    Location
    At work...
    Posts
    648
    This is the prompt:

    c:\> FTP -s:c:\upload ftp.serverx.net

    These are the lines of the file:

    USER myusername
    PWD mypassword
    cd /web
    lcd c:\brafpweb
    send c:\brafpweb\net-reach.htm net-reach.htm
    close
    quit

    Connected to serverx
    220 ProFTPD 1.2.5 Server (ProFTPD) [serverx]
    User (serverxnone)):
    331 Password required for USER.
    530 Login incorrect.
    Login failed.

    ftp> mypassword
    Invalid command.
    ftp> cd /web
    530 Please login with USER and PASS.
    ftp> lcd c:\brafpweb
    Local directory now C:\brafpweb.
    ftp> send c:\brafpweb\net-reach.htm net-reach.htm
    ftp> close
    221 Goodbye.
    ftp> quit

    Why am I not getting this right?? This would be useful for maintaining a website by having an automated upload each evening to reflect changes done to the site.
    Thanks

  18. #18
    Banned Michael_Kamen's Avatar
    Join Date
    May 2001
    Location
    The Netherlands
    Posts
    1,180
    Can't you just use the FTP API's ?

    FtpCreateDirectory
    FtpDeleteFile
    FtpFindFirstFile
    FtpGetCurrentDirectory
    FtpGetFile
    FtpPutFile
    FtpRemoveDirectory
    FtpRenameFile
    FtpSetCurrentDirectory
    InternetConnect

    Just a few API's you can use..

    If you download the API-Guide, it gives you examples for each one of them...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width