I cannot connect and upload to FTP via command line

I am unable to connect and upload files to some ftp using the BATCH file I made.

Also, I want to download all files from this local directory.

Please, help!

Thank.

Code:

@echo off
echo user username>> ftpcmd.dat
echo pass>> ftpcmd.dat
echo cd /public_html/reports/>> ftpcmd.dat
echo mput C:\automation\tests\HtmlReporter\*>> ftpcmd.dat
ftp -n -s:ftpcmd.dat myserver.com
del ftpcmd.dat
echo quit>> ftpcmd.dat
pause
disconnect
bye

      

Mistake:

 Connected to MYSERVER.com.
220---------- Welcome to Pure-FTPd [privsep] ----------
220-You are user number 23 of 500 allowed.
220-Local time is now 05:30. Server port: 21.
220-This is a private system - No anonymous login
220 You will be disconnected after 3 minutes of inactivity.
ftp> user USERNAME
331 UserUSERNAME OK. Password required

230-OK. Current restricted directory is /
230-111 files used (1%) - authorized: 10000 files
230 17049 Kbytes used (1%) - authorized: 1536000 Kb
ftp> prompt
Interactive mode Off .
ftp> cd /public_html/reports/
250 OK. Current directory is /public_html/reports
ftp> mput C:\automation\tests\HtmlReporter\*
Error opening local file C:\automation\tests\HtmlReporter\..
Error opening local file C:\automation\tests\HtmlReporter\...
200 PORT command successful

      

+3


source to share


1 answer


Take a look at this line:

echo password >> ftpcmd.dat

      

This doesn't actually store password

in the dat file, but password_

(_ is space). Try removing the spaces before >>

:



@echo off

echo user username>> ftpcmd.dat
echo password>> ftpcmd.dat
echo /public_html/reports>> ftpcmd.dat
echo mput c:\workspace\automation\HtmlReporter\Test_Report.html>> ftpcmd.dat
echo quit>> ftpcmd.dat
ftp -n -s:ftpcmd.dat servernamet.com
del ftpcmd.dat
pause
disconnect
bye

      

+2


source







All Articles