使用批处理文件的wget使用情况 [英] wget usage using batch file

查看:138
本文介绍了使用批处理文件的wget使用情况的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用wget在批处理文件中下载文件,如果文件已经准备就绪并且文件没有更改,我不想下载该文件,所以我正在使用-N 我也正在从个人FTP服务器下载文件,因此我想隐藏我的用户名密码详细信息,所以我决定使用>nul 2>&1隐藏输出 所以我的批处理文件是:

I am trying to download a file using wget in batch file,I don't want to download the file if the file all ready exist and it didn't change so I am using -N also I am downloading the file from my personal FTP server so I want to hide my username and password details so I decided to hide output using >nul 2>&1 so my batch file is:

@echo off
blah blah
.....
echo please wait...
wget -N ftp://XXXXXXXXXX@YYYYYYY.com/file.jpg >nul 2>&1 

现在有2个问题:

  1. 窗口标题仍将显示我的用户名&密码,如何隐藏标题或更改标题?

  1. The window title will still show my username & password , how I can hide the title or change the title ?

用户将不知道操作是否成功(完成下载)还是失败(不存在Internet或不存在文件),或者由于文件已经存在而未下载,我不知道是否可以进行3次IF操作.声明

the user wont know if the operation was successful (download was done) or fail (no Internet or no file exist) or it didn't download because the file already exist , I wonder if I can make 3 IF STATEMENTS

IF file was downloaded then echo file download

IF file wasn't downloaded then echo error

IF file wasn't downloaded because was the same then echo file didnt change

推荐答案

我同意PA的观点,即如果文件是敏感文件,那么就安全性而言,在控制台输出中隐藏密码不会有多大作用.但是,要回答OP的问题:

I agree with PA that if the file is sensitive then hiding the password in the console output won't do much in terms of security. However, to answer the OP's question:

1. title命令可以更改当前窗口的标题.

1. The title command is capable of changing the current window's title.

title My CMD Window

如果遇到的问题是出现wget命令的弹出窗口并在其中显示用户名和密码,则可以使用以下命令.抱歉,我对wget并不熟悉,所以我不确定wget的行为,希望对您有所帮助.

If the problem you're encountering is that a popup window for the wget command is coming up and displaying the username and password there, you can use the following. I apologize, I am not familiar with wget so I'm not sure on its behavior, hopefully this helps.

start "My WGET Window" wget -N ftp://XXXXXXXXXX@YYYYYYY.com/file.jpg >nul 2>&1

2. 之前和之后进行两次检查将是有益的.首先,检查文件是否存在,并且甚至不用wget来检查它是否已经存在(假设帖子中的措辞是您不想覆盖该文件).

2. A couple of checks before and after will be beneficial. First, check if the file exists and don't even bother with the wget if it does already exists (assuming from the wording of your post that you do not want to overwrite the file).

if exist file.jpg echo File already exists!&pause&goto :EOF
:: run wget here
if exist file.jpg (echo File download successful.) else (echo File download UNSUCCESSFUL.)

我们不需要检查所有三个条件,因为文件要么事先存在(在这种情况下批处理就退出了),要么在不存在的情况下我们测试下载是否成功.请注意,检查部分文件将很困难.

We don't need to check for all three conditions as the file either exists before hand (in which case the batch exits) or it does not in which case we test for a successful download. Note that it will be difficult to check for a partial file.

因此,将它们放在一起:

So, putting it all together:

@echo off
blah blah
.....
title My CMD Window
if exist file.jpg echo File already exists!&pause&goto :EOF
echo please wait...
start "My WGET Window" wget -N ftp://XXXXXXXXXX@YYYYYYY.com/file.jpg >nul 2>&1
if exist file.jpg (echo File download successful.) else (echo File download UNSUCCESSFUL.)

这篇关于使用批处理文件的wget使用情况的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆