|
Hello Guys, Is it possible to unzip the archive (.zip) in remote server right after uploading it? I am using SFTP for the upload process. Best Regards, Jepoy |
|
Although this operation (unzip file after uploading) is not supported by the SFTP protocol (and Rebex SFTP), it is often possible to achieve it by utilizing the fact that SFTP runs over SSH. This makes it possible to use SSH's "remote execute" feature to run arbitrary commands at the server (if it was configured to allow that, of course). To give it a try, use the following class:
To unzip a file located at the server, establish an SFTP connection, upload the file and call SftpCommandRunner.RunCommand, supplying a command to it. In the sample below, I used the
If you prefer VB.NET, please let me know. Does this work for you? |
|
Hello Matyska, What do you mean by exit code = 1 but the Error message is blank? Does it mean that the process is successful? I didn't change a think regarding to the SFTPCommandRunner class but i made a change to the later code you've shared as follow:
So when i execute this command: runner.RunCommand("site az2z") Any idea? I don't think it's possible to run 'quote "site az2z"' or 'size az2z' through SSH remote exec. SSH is not FTP and unless you have some very special server, its SSH part doesn't understand either 'quote' or 'site' commands. Try connecting to the server using an SSH client such as PuTTY to get into a shell session and test which commands are available.
(30 May '11, 12:27)
Lukas Pokorny ♦♦
|
|
Just to be sure here's my sftpcommandrunner class converted to vb.net
I also notice when i debug the code it never reach the event that we attached to the session. I would appreciate any correction and explanation as to what went wrong. thanks very much. hmmm... but matyska i tried this approach but it didn't unzip the file. and it did not went inside the event that's included in the sftpcommandrunner class.
(30 May '11, 12:09)
jepoy
1
There are three standard streams: input, output, error. The There is no rule, a program have to print it's error messages to the error output. Some programs prints its error messages to the standard output (mixed together with regular output). Therefore the I suggest you to write your if statement as follows:
If the
(30 May '11, 12:27)
Lukas Matyska ♦♦
I would say the most likely explanation is that 'quote' and 'site' commands are simply not available in the servers SSH subsystem. Are you able to run anything else, such as `echo test message'?
(30 May '11, 12:33)
Lukas Pokorny ♦♦
no i can't either. so you are saying that in order for me to run ftp command is to use rebex ftp class? otherwise that is impossible? looking forward to you answer :)
(30 May '11, 12:43)
jepoy
1
Yes, that seems to be the case with this server. FTP commands executed through 'site' command are usually FTP-only, and although many FTP servers make it possible to define custom FTP commands, these are usually not accessible through SSH remote exec even when both FTP and SFTP/SSH subsystems are provided by the same server. Depending on the server software, there might be some way to make the same or equivalent commands available through SSH as well, but we would need some information about the actual FTP and SFTP/SSH software installed at the server to be able to point you in the right direction.
(30 May '11, 14:04)
Lukas Pokorny ♦♦
Thank you very much guys. This tool is really the answer. Really appreciate your help guys.
(30 May '11, 15:09)
jepoy
Thank you very much pokorny. :)
(31 May '11, 09:02)
jepoy
showing 5 of 7
show 2 more comments
|