Using the library to connect to a remote server and copy a file. I have the process working fairly well but have some smaller things which I cant seem to resolve as documentation for the library is fairly thin.
I have two routines working. One using the Tamir.SharpSsh class and the other using the Tamir.SharpSsh.jsch class.
-
Using the Tamir.SharpSsh class I am able to copy the file from the local server to the remote server and tap into the pogress event. What I can’t do is determine if a particular file on the remote server say /Report/data.txt exists on the server. I need to take different actions if it exists or if doesn’t exist. Also how would I rename a file on the remote server. Ive tried using SshExec with a ‘rename’, ‘rn’, and ‘mv’ command and it doesn’t seem to work.
-
Using the Tamir.SharpSsh.jsch I can copy the file from the local server to the remote server. I can also rename the file on the remote server. What I cant do with this class is to tap into the progress event to keep track of the copy progress. Also I cant seem to find a good way to test to see if a particular file exists on the server. What I have come up with is crude and the only way that I could come up with to test and that is to use
Dim c As ChannelSftp Dim vct As Tamir.SharpSsh.java.util.Vector = c.ls(sRemoteFile) Dim cnt As Integer = vct.Count
When one or more file exists I get a count no problem. When there is no file then an exception is thrown.
Anyway, I have the routines working its just some minor things I need help with.
tia
AGP
You can call the
Tamir.SharpSsh.Sftp.GetFilemethod using the path of the file you want to check exists (example in C#, sorry):I have also noticed a few other issues through my use of this library – like a lack of a
GetFileInfomethod or recursive Gets and Puts. But overall it get the job done.The simple fact is, Tamir.SharpSsh can’t rename a file remotely – it just does not implement that functionality. You can purchase a better library that has far more features, such as:
or you could extend SharpSsh, since it is open source.