first time to create .bat ...

2009-01-30 3:31 pm
ipconfig /all
ftp -A download.speedtest.com.hk
get 100MBvideo.zip

after save as .bat , it stop at ftp>
but by hand is ok .. why?
(u can try yourself then u will know the problem ... by hand ok , autorun can't ...) any solution ?

回答 (2)

2009-02-01 7:47 am
✔ 最佳答案
You are incorrect in concept.
when you type ftp on command line, it has started the ftp program, so the next line you type is command to ftp program instead of to the command prompt.

When you execute a batch file, and entered ftp, the next line is another line execute under command line instead of enter into the ftp program, so after you exit the ftp program, it will execute the next line, but of course you will get another error.
to overcome, you may try the following, but it cannot resolve all problems
ipconfig /all
get 100MBvideo.zip | ftp -A download.speedtest.com.hk
2009-02-08 8:32 am
@echo off
rem FileSize= 10Mb or 100MB
set FileSize=10MB
if "%1"=="10MB" set FileSize=10MB
if "%1"=="100MB" set FileSize=100MB

set downloadcmdFile=downloadcmd.txt
set uploadcmdFile=uploadcmd.txt
set VideoFile=%FileSize%video.zip
set DownloadHost=download.speedtest.com.hk
set UploadHost=upload.speedtest.com.hk

if "%OS%"=="Windows_NT" goto SystemOK
Echo Warning: This script has been tested on Windows XP only.
echo Press Ctrl+C to end or
pause
:SystemOK

echo Start
rem Use 'ftp' as username and password
echo ftp> %downloadcmdFile%
echo ftp>> %downloadcmdFile%
echo get %VideoFile%>> %downloadcmdFile%
echo bye>> %downloadcmdFile%

rem Use 'ftp' as username and password
echo ftp> %uploadcmdFile%
echo ftp>> %uploadcmdFile%
echo put %VideoFile%>> %uploadcmdFile%
echo bye>> %uploadcmdFile%

cls
title SpeedTest (Ctrl-c to cancel)
echo This script will perform both download and upload tests by downloading and uploading a %FileSize% file with speedtest.com.hk.
echo.
echo Press Ctrl+C to end or
pause

echo ------------------------------------------------------------------
echo Performing Download test ......
ftp -s:%downloadcmdFile% %DownloadHost%

echo ------------------------------------------------------------------
echo Performing Upload test ......
ftp -s:%uploadcmdFile% %UploadHost%

del /q %VideoFile%
del /q %downloadcmdFile%
del /q %uploadcmdFile%

:End
pause
參考: Myself


收錄日期: 2021-04-13 16:23:33
原文連結 [永久失效]:
https://hk.answers.yahoo.com/question/index?qid=20090130000051KK00316

檢視 Wayback Machine 備份