windows 7 - File upload batch

07
2013-09
  • MChan

    I am trying to write a batch file that will Upload and update a specific set of file on my desktop to an FTP account, so I wrote this batch:

    @ftp -i -s:"%~f0"&GOTO:EOF
    open DomainName.com
    USERNAME
    PASSWORD
    binary
    cd  httpdocs/myfiles
    lcd F:\Test\Folder1
    mput *.bmp
    close
    quit
    

    by testing the above batch, everything work good until it reaches the line:

    mput *.bmp
    

    once this line is reached, connection freeze and the only way to resume after that is by restarting the router

    So can someone please help me by telling me what exactly I am doing wrong here?

    Update: 1. FTP server I am trying to upload to is Linux based (CentOS) 2. I am using a Windows XP - SP1 machine to execute this batch file 3. I've tried clicking CTRL+C to terminate the batch but still, even though the batch is terminated the connection remain freezed until I restart the router

    Update 2: Here is the exact output of the commands I enter:

    ftp
    open domainname.com
    220 ProFTPD 1.3.4a Server <ProFTPD> [IP ADDRESS of our server]
    User <domainname.com:<none>>: USERNAME
    331 Password required for USERNAME
    Password: PASSWORD
    230 User USERNAME logged in
    ftp> binary
    200 Type set to I
    ftp> cd httpdocs/myfiles
    250 CWD command successful
    ftp> lcd F:\Test\Folder1
    Local directory now F:\Test\Folder1
    ftp> mkdir MyTest1
    257 "/httpdocs/myfiles/MyTest1" - Directory successfully created
    ftp> put test.bmp
    

    Freeze connection and router

  • Answers
  • Scott

    After

    lcd F:\Test\Folder1
    

    try

    lcd F:\Test\Folder1
    mkdir MyTest
    

    Check that MyTest was created properly. I suspect that your router can't find the directory but isn't throwing an error. When the transfer begins is when it is caught.

    I don't see anything wrong with

    mput *.bmp
    

  • Related Question

    FTP script won't transfer remote files to local computer
  • roman m

    This is a follow up to FTP BAT file - Windows Scheduled Task.

    I copied the FTP script, but I can't transfer the files to my local computer.

    All I get is this (server address omitted):

    331 Password required for ftpdemo.
    
    230 User ftpdemo logged in.
    ftp> lcd C:\Temp\Test
    Local directory now C:\Temp\Test.
    ftp> mget ErrorLog\*.*
    200 Type set to A.
    mget LogViewer.asp? quit
    ftp>
    

    Here's the actual script:

    open ftp.myserver.com
    ftpdemo
    pass
    lcd C:\Temp\Test
    mget ErrorLog\*.*
    quit
    

    What do I need to fix?

    UPDATE:

    used PROMPT, now it loops through all the files, but keeps saying the following:

    200 port command successful
    550 "file_name_here": no such file
    

    and same goes for every file in the directory ... it lists all the files, so they ARE there, I have no idea what's wrong. Also, I use the same account that I use for GUI ftp, and permissions should not be an issue.

    Any ideas?

    UPDATE 2:

    here's how i got it to work (thanks to dave lozinski's site):

    open ftp.myserver.com
    ftpdemo
    pass
    lcd C:\Temp\Test
    cd /ErrorLog
    prompt
    mget *.*
    quit
    

    basically I just had to change the directory on the server.


  • Related Answers
  • Stewart Robinson

    Before the mget command add a line that says

    prompt
    
  • harrymc

    Perhaps ftp -i will solve the problem.

    This parameter turns off interactive prompting during multiple file transfers, which is the prompt that I see in the post.