2013-12-13 51 views
0

我正在嘗試爲用戶編寫一個簡單的密碼重置提示的.bat文件,而我需要做的最後一件事就是退出,由於某種原因而沒有執行該操作。進程在連接完成後暫停,quit命令將被忽略,並且在進程恢復之前必須手動輸入。如何在腳本中退出FTP?

以下是我有:

@echo off 
Echo Password Reset Process 
Pause 
Echo Enter your user ID when asked 
Echo --- 
Echo Change your password by using this format, including the slashes: 
Echo 'oldpassword/newpassword/newpassword' 
Echo --- 
Echo You will not be able to see what you type 
Echo So proceed carefully! 
Echo --- 
Echo Begin Your Password Reset Now? 
Pause 
FTP Server.domain.org 
Quit 
Pause 
exit 

謝謝!

回答

0

試試這個:

@echo off 
Echo Password Reset Process 
set /P "userID=Enter your user ID: " 
Echo Enter your new password by using this format, including the slashes: 
set /P "password=oldpassword/newpassword/newpassword: " 
Echo Begin Your Password Reset Now? 
Pause 
(
echo %userID% 
echo %password% 
echo Quit 
) > passfile.txt 
FTP -s:passfile.txt Server.domain.org 
del passfile.txt 
exit 
+0

這樣做,非常感謝。 – XB1213

0

批處理文件只包含Windows shell cmd.exe的命令。如果你想輸入命令到其他程序中,你必須使用它的方式來完成。

使用FTP,您可以使用-s:filename開關,請參閱ftp -h。所以你可以創建一個文件,說ftp-cmd.txt,必要的行,並結束行quit,然後在批處理文件中調用ftp -s:ftp-cmd.txt。這應該夠了吧。

+0

感謝您的信息! – XB1213