Batch file not accepted. Parameter as% 1,% 2

I have a simple script that loads ftp, the main thing is that I want to pass parameters such as host name, username, password, etc. to file bat.

This is my script.

@ftp -i -s:"%~f0"&GOTO:EOF
open %1
%2
%3
!:--- FTP commands below here ---
lcd "%4"
cd  %5
binary
put "%6"
disconnect
bye

Now, when I call the script from the command line and pass in %1, %2... the content %1, %2will be replaced by my command line parameters. This is my command line:

ftp.bat "first" "second" "third" "forth" "five" "six"

Instead %1it becomes first, %2it becomes second, etc., it %1remains %1, so in essence I open the ftp side with a name %1that is completely meaningless.

Anything I'm doing wrong?

0
2

, , , script .

FTP script, .

( , ):

@setlocal enableextensions enabledelayedexpansion
@echo off
set tmpfl=%~f0.tmp
echo>"%tmpfl%" open %1
echo>>"%tmpfl%" %2
echo>>"%tmpfl%" %3
echo>>"%tmpfl%" lcd "%4"
echo>>"%tmpfl%" cd %5
echo>>"%tmpfl%" binary
echo>>"%tmpfl%" put "%6"
echo>>"%tmpfl%" disconnect
echo>>"%tmpfl%" bye
type "%tmpfl%" && rem ftp -i -s:"%tmpfl%"
del /q "%tmpfl%"
endlocal

type. script, :

type "%tmpfl%" && rem ftp -i -s:"%tmpfl%"

ftp -i -s:"%tmpfl%"
+1

, ftp -s - "% ~ f0" , . ftp , % 1,% 2 .. . , ftp-.

"echo open% 1 > temp.txt" .., ftp-.

:

echo open %1 > temp1.txt
echo %2 >> temp1.txt
echo %3 >> temp1.txt
rem !:--- FTP commands below here ---
echo lcd "%4" >> temp1.txt
echo cd  %5 >> temp1.txt
echo binary >> temp1.txt
echo put "%6" >> temp1.txt
echo disconnect >> temp1.txt
echo bye >> temp1.txt
@call ftp -i -s:"temp1.txt"&GOTO:EOF
0

All Articles