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
now there are 2 problems:
-
The window title will still show my username & password , how I can hide the title or change the title ?
-
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
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.
The title command is capable of changing the current window’s title.
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.
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).
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: