简体   繁体   English

Windows批处理脚本:ftp命令:等待用户登录

[英]Windows batch script: ftp command: wait for the user to log in

I´d like to make Windows .cmd script file. 我想制作Windows .cmd脚本文件。 One of its commands makes use of the ftp command. 它的命令之一使用ftp命令。 When I execute the batch script, the commmand prompt does not wait for the user to type his user/password, so the next commands are not properly executed. 当我执行批处理脚本时,命令提示符不会等待用户键入其用户名/密码,因此下一条命令将无法正确执行。 How can I make it to pause? 如何使其暂停?

Thanks. 谢谢。

Edited: 编辑:

My question was more related to the interactive use of the command ( -i option) than the automatic login ( -n option). 我的问题与命令的交互式使用( -i选项)比自动登录( -n选项)更相关。 I want to wait for the user to enter their credentials. 我要等待用户输入其凭据。

Also, I have seen that by typing the command: 另外,通过输入命令,我已经看到了:

ftp -n -i -s:myFtpCommands.txt 192.168.0.20

and that myFtpCommands.txt contains: 并且myFtpCommands.txt包含:

use myUser
mget *
bye

There is no need to type the password to get files. 无需输入密码即可获取文件。 Where is the associated security problem? 相关的安全问题在哪里?

You could ask the user for their details before hand, then build the command file based on their input. 您可以事先询问用户详细信息,然后根据他们的输入来构建命令文件。

@echo off
set /p un=Enter your FTP username:
set /p pw=Enter your FTP password:
echo open 192.168.0.20 >ftpscript.txt
echo %un% >>ftpscript.txt
echo %pw% >>ftpscript.txt
mget * >>ftpscript.txt
bye >>ftpscript.txt
ftp -i -s:ftpscript.txt

With regards to the auto login, this is a feature of FTP, it's an anonymous login, that is setup on FTP servers to allow this sort of access. 关于自动登录,这是FTP的功能,它是匿名登录,在FTP服务器上设置为允许这种访问。

Whoever setup the FTP server would be able to control the accounts that are allowed to be used to access the server, and the permissions on the files that they don't want everyone to have access to. 设置FTP服务器的任何人都可以控制允许用于访问服务器的帐户,以及他们不希望所有人都可以访问的文件的权限。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM