Escaping characters in batch scripts

I have the following script to automate uploading a file to a remote server. The problem is that the password I entered is filled with special characters that kill the login process.

Here is the modified version of the characters:

J7 ~]% & X

Using a regular FTP application is not a problem. I wrapped the password in quotation marks and also tried to use ^it to avoid percent and ampersand. However, this does not work. In addition, I can’t say which password is being sent.

What can happen wrong or how can I open a password before sending it?

:Source = http://www.howtogeek.com/howto/windows/how-to-automate-ftp-uploads-from-the-windows-command-line/

@echo off
echo user myloginname> ftpcmd.dat
echo mypassword>> ftpcmd.dat
echo bin>> ftpcmd.dat
echo put %1>> ftpcmd.dat
echo quit>> ftpcmd.dat
ftp -n -s:ftpcmd.dat myserver
del ftpcmd.dat

Decision

, "type", , ftpcmd.dat. , escape- escape- !!!

, . , :

J7 ~]% &

:

J7 ~] %% ^ &

+3
3

, , .

, "" , .

@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

- ftp, . , ( ) . , for-loop

+4

FTP- , - Wireshark , .

, .

+1

FYI, ^. , echo > , , . :

echo ^<html^> >> foo.txt
+1

Source: https://habr.com/ru/post/1767852/


All Articles