c# - How to properly run “top” command through SSH? -
i'm using library connect linux commands run , run commands have problems
for example, have problem running these commands:
top , top -n 1
error:term environment variable not set
private void button2_click(object sender, eventargs e) { renci.sshnet.sshclient sshclient = new renci.sshnet.sshclient("192.168.150.128", "reza", "1"); sshclient.connect(); var command = sshclient.runcommand("top"); var line = command.result.split('\n'); list<serverstatuscpu> serverstatus = new list<serverstatuscpu>(); (int = 3; < line.length - 1; i++) { var li = line[i]; var words = li.split(' '); list<string> fillterwords = new list<string>(); foreach (var w in words) { if (w != "") { fillterwords.add(w); } } serverstatuscpu serverstatus = new serverstatuscpu(); serverstatus.time = fillterwords[0]; serverstatus.timetype = fillterwords[1]; serverstatus.name = fillterwords[2]; serverstatus.usercputime = float.parse(fillterwords[3].replace("%", "")); serverstatus.usernicecputime = float.parse(fillterwords[4].replace("%", "")); serverstatus.systemcputime = float.parse(fillterwords[5].replace("%", "")); serverstatus.iowaitcputime = float.parse(fillterwords[6].replace("%", "")); serverstatus.irqcputime = float.parse(fillterwords[7].replace("%", "")); serverstatus.softwareirqcputime = float.parse(fillterwords[8].replace("%", "")); serverstatus.stealcputime = float.parse(fillterwords[9].replace("%", "")); serverstatus.guestcputime = float.parse(fillterwords[10].replace("%", "")); serverstatus.idlecputime = float.parse(fillterwords[11].replace("%", "")); serverstatus.add(serverstatus); } datagridview1.datasource = serverstatus; } class serverstatuscpu { public class serverstatuscpu { public string time { get; set; } public string timetype { get; set; } public string name { get; set; } public float usercputime { get; set; } public float systemcputime { get; set; } public float usernicecputime { get; set; } public float idlecputime { get; set; } public float iowaitcputime { get; set; } public float irqcputime { get; set; } public float softwareirqcputime { get; set; } public float stealcputime { get; set; } public float guestcputime { get; set; } } }
the problem having related fact server not know term input should redirected.
please have @ http://www.linuxquestions.org/questions/programming-9/term-environment-variable-not-set-593180/
you need set term variable before being able obtain output.
Comments
Post a Comment