Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
in General by (140 points)

Does edtftpj-pro support remote execution of commands via ssh, or is it strictly limited to file transfer operations?

1 Answer

0 votes
by (4.4k points)
Yes, edtftpj-pro does support this.
by (140 points)
Thanks for confirming. I was going through examples but didn't find it, but was able to find the method in the javadoc.

For anyone else that might be looking, it's the executeCommand(String command) method, which makes this super easy.

by (140 points)
One more hint for anyone that might find this later. The executeCommand method checks the exit code of the command and will throw an FTPException if it is non-zero. This means that if you do something like executeCommand("/directory/that/may/not/exist"); and the directory does not exist, you'll get an FTPException rather than the output of the command.

If you want to avoid the FTPException, add a command that will always succeed to the end of the command string. Then, the exit code is 0 and the method will return any results that ended up on stdout. So: executeCommand("/directory/that/may/not/exist;true");

It would be nice to have another executeCommand method that returned stderr, stdout, and exit code, but in the meantime this will work around the issue.