batch-filecmdfilezillacrypt

How to read an output of filezilla-server-crypt command with a cmd/batch script?


in order to migrate an FTP database to an SFTP database, I need to create a script that modifies a xml file.

For the user, I need to encrypt the password.

I've found that a file called filezilla-server-crypt can be used in a cmd to encrypt a password.

However, when this command is used, the return is automatic.

For my script, I therefore need to read the result of the command in order to recover the encrypted password and the salt.

Here is my code in the cmd script:

net use a : \\Test$
for /f "tokens=*" %%a in ('a:\filezilla-server-crypt test echo test') do set "line=%%a"
echo line :
echo %line%
net use a : /delete

Even if I use start a:\filezilla-server-crypt test echo test the %line% variable is empty.

Do you have an idea how to retrieve the result?


Solution

  • If the answer above doesn't work, you can use this technique:

    SET /p supplierMail=Enter the supplier's e-mail address :
    
    SET /p=%supplierPswd%<nul >> C:\temp.txt
    
    FOR /f "delims=" %%G IN ('A:\filezilla-server-crypt.exe test ^< C:\temp.txt') DO SET "line=%%G"
    
    DEL C:\temp.txt
    

    This method use a temporary file which contains the password in order to implement it (a variable can't be implement with < that's why I use a file) in the window generated by this command :

    A:\filezilla-server-crypt.exe test
    

    The difference whith the other method is that the other method delete the error messages with this: 2^>NUL so for all situations, the code will return a value even if it is false.