2017-12-20 20 views
1

FTP를 통해 서버에 업로드하려는 폴더가 몇 개 있습니다.배치 스크립트에서 FTP를 통해 디렉토리의 파일과 폴더를 업로드 할 수 없습니다.

@echo off 
echo user USERNAME> ftpcmd.dat 
echo PASSWORD>> ftpcmd.dat 
echo prompt>> ftpcmd.dat 

echo cd %1>> ftpcmd.dat 
echo lcd %2>>ftpcmd.dat 
echo mput *.*>> ftpcmd.dat 
echo quit>> ftpcmd.dat 
ftp -n -s:ftpcmd.dat 123.456.78.9 
del ftpcmd.dat 
pause 

그리고 한 줄이 run_ftp.bat, public_html/ 서버에있는 파일의 대상이며 C:\Web\build 곳이다 : 나는 fileup.bat

build > 
    fonts > 
     - font1.ttf 
     - font2.ttf 
    images > 
     - img1.png 
     - img2.png 
    javascripts > 
     - script.js 
    stylesheets > 
     - style.css 
    index.html 

:

은 폴더 구조 파일은 내 PC에 있습니다 :

fileup public_html/ C:\Web\build 

run_ftp.bat은 C : \ Web에 있으며 fileup.bat은 C : \ Windows에 있으므로 PATH에 나타나서 cmd에서 fileup을 실행할 수 있습니다.

run_ftp.bat을 실행하면 서버에 업로드되는 파일 만/build의 루트에 있으므로 index.html 만 업로드됩니다. 콘솔은/build 내부의 각 폴더에 대해 Error opening local file fonts.을 기록합니다. 파일의

230 OK. Current restricted directory is/
ftp> prompt 
Interactive mode Off . 
ftp> cd public_html/ 
250 OK. Current directory is /public_html 
ftp> lcd C:\Web\build 
Local directory now C:\Web\build. 
ftp> mput *.* 
Error opening local file fonts. 
Error opening local file images. 
200 PORT command successful 
150 Connecting to port 57128 
226-File successfully transferred 
226 0.142 seconds (measured here), 1.78 Mbytes per second 
ftp: 265174 bytes sent in 0.07Seconds 3682.97Kbytes/sec. 
Error opening local file javascripts. 
Error opening local file stylesheets. 
200 PORT command successful 
150 Connecting to port 57129 
226-File successfully transferred 
226 0.033 seconds (measured here), 36.90 Kbytes per second 
ftp: 1229 bytes sent in 0.01Seconds 102.42Kbytes/sec. 
ftp> quit 
221-Goodbye. You uploaded 261 and downloaded 0 kbytes. 
221 Logout. 
Press any key to continue . . . 

없음 나는 폴더 중 어느 것도 업로드되지되는 이유는 조금 난처한 상황에 빠진거야, 내가 .bat 파일을 실행하면 빌드 폴더 안에 폴더를 사용중인 없습니다 : 여기

로그입니다 . 나는 을 ascii으로 바꾸려고 시도했지만 아무것도하지 않습니다.

+0

에서만 디렉토리의 소수가 (나는 WinSCP에의 저자 해요). 몇 가지 디렉토리 명령을 변경 한 다음 mput 명령을 사용하여 파일을 업로드하십시오. – Squashman

답변

1

Windows 명령 줄 ftp.exe 클라이언트는 재귀 작업을 지원하지 않습니다.

타사 FTP 클라이언트를 사용해야합니다.


WinSCP와 예를 들어, 당신은 사용할 수 있습니다

winscp.com /log=ftp.log /command^
    "open ftp://USERNAME:[email protected]/"^
    "mput ""%2\*"" ""%1"""^
    "exit" 

converting Windows ftp.exe script to WinSCP script위한 가이드가있다. 더 쉬울지라도 WinSCP GUI generate the script or batch file for you이 있어야합니다.