SSH Execute command - WeOnlyDo Discussion board

SSH Execute command (wodSSH / wodSSH.NET)

by Robert, Thursday, October 14, 2004, 01:26 (7357 days ago)

I've written a program in C#, su - to root and after the conection and then the following works: then last does not? Is it because the return from cat /etc/group is more than one line?

string s, cmd;
Ssh1.Blocking=true;
cmd = grep + User + /etc/shadow
;
s = Ssh1.Execute(cmd);//Ssh1.Send( grep + User + /etc/passwd
);
DisplayUserShadowFileDetails(s.Substring(cmd.Length).TrimEnd(
.ToCharArray()));
Ssh1.Blocking=false;

Broken:
string s, cmd;
Ssh1.Blocking=true;
cmd = cat /etc/group
;
s = Ssh1.Execute(cmd);
s = s.Substring(cmd.Length).TrimEnd(
.ToCharArray());
Ssh1.Blocking=false;
String[] Groups = s.Split(
.ToCharArray());

Re: SSH Execute command

by wodSupport, Thursday, October 14, 2004, 01:29 (7357 days ago) @ Robert

Robert,

I think problem is elsewhere. Execute method doesn't just execute some command. It also waits until expected response is returned. What response do you expect? Prompt? Did you set it? Oh, somewhere outside this code?

Check out what does Execute return to you. Perhaps results you need are returned with that call? If not, call Receive method later on.