tFtp, sftp, and remote directory

Four Stars

tFtp, sftp, and remote directory

These three things are causing an issue. I have a job that uses the tFtp component with sftp enabled. If I test it on any other site, it works fine, -IF- I include a remote directory.
However, for a site that I am trying to download files from, it does not have a remote directory, when I log in, it directly drops me in the directory where the files are located. So if I leave Remote Directory empty, or with a a space " ", or even "/" I get errors. For example, I left a space in remote directory and I got this error:
Exception in component tFTPGet_2
2: No such file: / /.
at com.jcraft.jsch.ChannelSftp.ls(ChannelSftp.java:1315)
at ftpservice.ftpget_0_2.FTPGet$1SFTPGetter_tFTPGet_2.getFiles(FTPGet.java:551)
at ftpservice.ftpget_0_2.FTPGet.tFTPGet_2Process(FTPGet.java:678)
I looked up and down jcraft.jsch but cannot find what is causing this issue. Like I said, I have another ftp site that includes all the parameters and it works fine...but when I need it for an ftp site that does not require a remote directory, I get all sorts of errors.
Could this be a bug?
thanks
One Star

Re: tFtp, sftp, and remote directory

perhaps you can try "./" in remote directory ?
One Star

Re: tFtp, sftp, and remote directory

You can also try just the dot "." if "./" does not work
Four Stars

Re: tFtp, sftp, and remote directory

Well, I was able to contact the company hosting the FTP server and they are able to create a directory and drop the files there which solves my issue.
However, for future reference, I am going to try both of your replies:
If I put "./" this is the error:
Exception in component tFTPGet_2
3: Permission denied.
at com.jcraft.jsch.ChannelSftp.throwStatusError(ChannelSftp.java:2283)
at com.jcraft.jsch.ChannelSftp._stat(ChannelSftp.java:1737)
at com.jcraft.jsch.ChannelSftp._stat(ChannelSftp.java:1754)
at com.jcraft.jsch.ChannelSftp.get(ChannelSftp.java:780)
at ftpservice.ftpget_0_2.FTPGet$1SFTPGetter_tFTPGet_2.downloadFile(FTPGet.java:582)
If I put ".":
Exception in component tFTPGet_2
3: Permission denied.
at com.jcraft.jsch.ChannelSftp.throwStatusError(ChannelSftp.java:2283)
at com.jcraft.jsch.ChannelSftp._stat(ChannelSftp.java:1737)
at com.jcraft.jsch.ChannelSftp._stat(ChannelSftp.java:1754)
at com.jcraft.jsch.ChannelSftp.get(ChannelSftp.java:780)
at ftpservice.ftpget_0_2.FTPGet$1SFTPGetter_tFTPGet_2.downloadFile(FTPGet.java:582)
I tried other combos like "/../" and "~/" and nothing works.
This seems to be an issue in the actual jsch library. It tries to change to the directory using "cd" and then it downloads the file using the absolute path. In reality, it should just use one or the other...not both. My issue would have been solved if that was the case.
To clarify, its not an issue with the server. They created an "outgoing" directory and I changed my remote directory to "/outgoing" and the job is now working fine.
One Star

Re: tFtp, sftp, and remote directory

##########################################################
4: not supported to get directory /csptest
at com.jcraft.jsch.ChannelSftp.get(ChannelSftp.java:788)
at com.jcraft.jsch.ChannelSftp.get(ChannelSftp.java:750)
at jschSftp.main(jschSftp.java:36)
###########################################################
Not able to copy directory how can i copy directory.
One Star

Re: tFtp, sftp, and remote directory

ok i got the answer with 3 days/night hard work that its an error in their jar.I than used jsch 0.1.42 jar and got the function ChannelSftp.LsEntry which has function named getlongname and getfilename problm solved. U can contact me on csp.dhoom@gmail.com Smiley Happy
One Star

Re: tFtp, sftp, and remote directory

hello,
can you tell me how you did?
thanks
One Star

Re: tFtp, sftp, and remote directory

Can you please give an example how to use LsEntry.
Thanks in advance
One Star

Re: tFtp, sftp, and remote directory

I have requirement to ftp the file to server where put command should be similar to following:
>sftp user@hostaddress
>password
>cd //
>put localfilename //!remotefilename
Using ChannelSftp, I am having challenge to send the double-qoutes.
In my code, I pass the arguments as following:
JSch jsch = new JSch();

Session session = null;
ChannelSftp sftpChannel = null;

try
{
// Getting the session
session = jsch.getSession(userID, host, 22);

// Ignore HostKeyChecking
session.setConfig("StrictHostKeyChecking", "no");

// set the password for authentication
session.setPassword(password);
session.connect();

// Getting the channel using sftp
Channel channel = session.openChannel("sftp");
channel.connect();

sftpChannel = (ChannelSftp) channel;

// Going to folder
sftpChannel.cd("//");

// Perfrom the file operation using sftpChannel
sftpChannel.put("localfilename", "//!remotefilename");

}
catch (JSchException e )
{
e.printStackTrace();
}
catch (SftpException e)
{
e.printStackTrace();
}
finally
{
// Exist the channel
sftpChannel.exit();

// Disconnect the session
session.disconnect();
}

When I execute it,
I am getting following error: 2 File not exist
Somehow it is not treating // as part of the arguments and keept taking them off. I have also tried //// in order to make program think that it is part of the argument but still no success.
Any idea how can I make sure that // are taken as part of argument and should not be deleted by program
Thanks in advance!
One Star

Re: tFtp, sftp, and remote directory

We are having a similar error with the Stat routine of jSch.  The file is consumed immediately upon upload so jsch cannot read the file to confirm it was uploaded.  Is there anyway to have Talend just put the file there without checking that it got there?