Я создал тестовый файл на моем диске D.Моя цель - загрузить его на мой сайт из сценария VBA в Excel.Когда я запускаю .bat файл, он зависает во время сдачи.Что я делаю неправильно?Я закомментировал строку /, потому что это дало мне ошибку.
Ответ при запуске upload.bat из командной строки
D:\>upload.bat
D:\>ftp -i -s:d:\script.dat domain.com
Connected to domain.com.
220 *** FTP Server Ready
200 UTF8 set to on
User (domain.com:(none)):
331 Password required for username
230 User username logged in
ftp> put d:\test.txt
200 PORT command successful
425 Unable to build data connection: Connection timed out
ftp> quit
221 Goodbye.
enter code here
Sub ftp()
Dim fs As Object
Set fs = CreateObject("Scripting.FileSystemObject")
Set a = fs.CreateTextFile("d:\script.dat", True)
a.writeline "username" 'username
a.writeline "password" 'password
'a.writeline "\" 'directory on FTP site
a.writeline "put d:\test.txt" 'file to be uploaded
a.writeline "quit"
a.Close
Set fs = CreateObject("Scripting.FileSystemObject")
Set a = fs.CreateTextFile("d:\upload.bat", True)
a.writeline "ftp -i -s:d:\script.dat domain.com" 'the ftp site
a.Close
dRetVal = Shell("d:\upload.bat", 0) 'upload the file
Application.ScreenUpdating = True
End Sub