Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
2.8k views
in Java FTP by (780 points)
Hi there,
I am having a little bit of trouble resolving variables set.

As an example. I have a script with the following:

set myUserPassword=FooBar01
echo $myUserPassword
SITE CPWD $myUserPassword

This would return the following:

FooBar01
SITE CPWD $myUserPassword


Resulting in the password for the user in question being changed to '$myUserPassword'
I have tried a few other variations but would like to know what, fundamentally, am I doing wrong here.

3 Answers

0 votes
by (161k points)
Use of variables is quite limited - the site command (and most other commands) do not do variable substitution.

The variables supported are predefined ones that are used in various commands such as open.
0 votes
by (780 points)
Cheers,
I got around the issue by reading the script file in, performing a Java ReplaceAll on variables I designated with %newUserPassword% and running the commands one at a time using the ScriptEngine RunCommand method. A little ugly but it allows me to pass in custom SITE commands for changing passwords on different SSL FTP servers with different change password protocols.


Regarding the SSH FTP Client to change passwords remotely:
I ran the SSHFTPClient.setAuthenticationChangePassword(userName, userPassword, newUserPassword) method against the CompleteDT FTP Server. it succeeded in changing the password even though both PublicKeyAndPassword had been set as required on the FTP Server.

So when I ran the SSHFTPClient.connect() method the password was successfully changed but authentication failed as I did not have a public/private keypair configured.
I tested this by catching the error and running SSHFTPClient.setAuthentication(ftpClientPrivateKeyFile, userName, ftpClientPrivateKeyPassword, newUserPassword) command and successfully connected.

Two things to note here:

1. It appears as though the setAuthenticationChangePassword method does not allow keypairs to be passed in, or I have not found an overloaded/equivalent method as of yet that does allow private/public keypairs to be passed in the change password prompt.

2. There may be an error in the Complete FTP Server (7.4) edition whereby passwords can be changed without the private/public keypairs, even when the supported authentication methods in the 'Advanced SFTP/SCP' settings are set to 'PublicKeyAndPassword' only.
0 votes
by (161k points)
Thanks for the followup.

It seems that password change should fail using this password-only method if PublicKeyAndPassword only is set - we'll investigate.

Categories

...