How do you specify the username in ftp upload by a

2019-09-06 11:56发布

问题:

I want to make a batch that auto uploads important files from the user that is using the program. so what I did was %username% in the directory Ex. C:\user\%username%\importantfiles

open (ftp server name)
(ftp user-name)
(ftp password)
prompt
bin
mput c:\user\%username%\importantfiles 

There are many users that must be able to use this..

So the "C:\user\mike\importantfiles" will not work

So the question is How do you specify the username in ftp upload

回答1:

You will need to generate the ftp script file from your batch.

Something like (just a skeleton)

....
set "ftpScript=%temp%\%~nx0.ftp.tmp"
(
    echo open (ftp server name)
    echo (ftp user-name)
    echo (ftp password)
    echo prompt
    echo bin
    echo mput "c:\user\%username%\importantfiles\*.*"
    echo quit
) > "%ftpScript%"

ftp -s:"%ftpScript%"
del /q "%ftpScript%" >nul 2>nul
....