Commands started using Ssh.StartCommand
or Ssh.RunCommand
are independent. They run over the same SSH session, but they are not executed from a single shell. The first command changes its current directory and ends, but the second command doesn't know anything about the environment of the first one.
Most Unix servers make it possible to use the ';'
character to run multiple commands that share the same environment. Please try this:
Shell s1 = client.StartCommand("cd bea/user_projects/domains/gds/gdsmeterlogs/gdssdk/Archive ; cat meter_sdk_nj09mhf0108.mhf.mhc.log.c_2014-02-12*");
r += s1.ReadAll();
string[] lines = Regex.Split(r, "\n");
System.IO.File.WriteAllLines(@"C:\Users\ssameer\Downloads\test\abc.txt", lines);
MessageBox.Show("done");