I have the following script to automate uploading a file to a remote server. The problem is that the password I have been given is full of special characters which are killi
FTP passwords are sent in plain text so installing something like Wireshark will allow you to see what is being sent.
I would expect you would need to prefix the special characters with a backslash.
FYI, character prefixing is done with ^. So if you were doing an echo
with >
in the string but writing a file, it will fail without escaping. The syntax would be:
echo ^<html^> >> foo.txt
In your case you could simply type your file to reveal the password, just before you delete the file.
But it's better to use the delayed expansion, because then the special characters lose their "special" behaviour, even carets and percent signs.
@echo off
setlocal EnableDelayedExpansion
set /p passwd=Enter pwd
echo user myloginname> ftpcmd.dat
echo mypassword>> ftpcmd.dat
echo bin>> ftpcmd.dat
echo put !passwd! >> ftpcmd.dat
echo quit>> ftpcmd.dat
type ftpcmd.dat
ftp -n -s:ftpcmd.dat myserver
The second problem is the ftp command, where the characters also need escaping. Perhaps (like Vicky wrote) the backslash could work. You can place it before each single character, by using a for-loop