Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I am using unzip through putty and it works ok. However, using the same command through a .NET C# SSH library (Renci.SshNet) gives different results.

SshClient s = new SshClient("ssh_host", "ssh_port", "ssh_username", "ssh_password");
SshCommand c = s.RunCommand("unzip -o \"/home/parent/child/1.zip\ 1.txt"")

This same command through putty, extracts it in 'child', using this, the 1.txt ends up in 'parent'. The return result of the Sshcommand is the same as Putty's return :

Archive:  /home/parent/child/1.zip
extracting: 1.txt

Why is it extracting one level up? The only difference i can see is that i used cd to position myself to the directory (in Putty).

share|improve this question

2 Answers 2

up vote 3 down vote accepted

Or use unzip's -d option to specify the directory to which to extract files.

SshCommand c = s.RunCommand("unzip -d /home/parent/child -o \"/home/parent/child/1.zip\ 1.txt"")
share|improve this answer
    
+1 Any other advantages to using this? –  JJ_Jason Sep 29 '12 at 18:39

Got it.

SshCommand c = s.RunCommand("cd /home/parent/child/ && unzip -o 1.zip 1.txt"))

Using this syntax i position my self to the folder and do the unzip.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.