远程服务器的命令提示输出的对齐方式 [英] Alignment of command prompt output of remote server

查看:104
本文介绍了远程服务器的命令提示输出的对齐方式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我的程序是通过C#程序访问远程系统的命令提示符。我能做到。但问题是输出的对齐。

任何人都可以提出对齐输出的想法吗?



这里是我的代码...... ...........



尝试

{

SshShell ssh1 =新的SshShell(主机,用户,通行证);


SshStream ssh =新的SshStream(主机,用户,通行证);

Console.WriteLine(" ------ Connecting ......");

ssh1.Connect();

Console.Write(" ; OK");

Console.WriteLine();

//ssh.Prompt =" $";


ssh1.RemoveTerminalEmulationCharacters = true;

Console.Write(ssh1.Expect(" $"));

//ssh1.Expect("$" );

while(true)

{

Console.Write(" Ent the cmd) :");

string command = Console.ReadLine();

if(command.ToLower()。Equals(" exit"))

休息;

ssh1.WriteLine(命令);

string out1 = ssh1.Expect(">");

out1 = out1.Replace(" "," \ n");

out1 =" \ n" + out1;

Console.WriteLine(out1);

//Console.WriteLine(ssh1.Expect(">"));


}

ssh1.Close();

ssh.Close();

Console.WriteLine(" Connection closed。 ");


}

Hi,

My program is access the remote system''s command prompt through C# program. I can do it. But problem is alignment of that output.
can any one give idea to align that output ?.


here is my code......................



try
{
SshShell ssh1 = new SshShell(host,user,pass);

SshStream ssh = new SshStream(host, user, pass);
Console.WriteLine("------Connecting...");
ssh1.Connect();
Console.Write("OK");
Console.WriteLine();
//ssh.Prompt ="$";

ssh1.RemoveTerminalEmulationCharacters = true;
Console.Write(ssh1.Expect("$"));
//ssh1.Expect("$");
while (true)
{
Console.Write("Ent the cmd:");
string command = Console.ReadLine();
if (command.ToLower().Equals("exit"))
break;
ssh1.WriteLine(command);
string out1 = ssh1.Expect(">");
out1 = out1.Replace(" ", "\n ");
out1 = "\n" + out1;
Console.WriteLine(out1);
//Console.WriteLine(ssh1.Expect(">"));

}
ssh1.Close();
ssh.Close();
Console.WriteLine("Connection closed.");

}

推荐答案

" ;;


ssh1 .RemoveTerminalEmulationCharacters = true;

Console.Write(ssh1.Expect("
";

ssh1.RemoveTerminalEmulationCharacters = true;
Console.Write(ssh1.Expect("


"));

// ssh1 .Expect("
"));
//ssh1.Expect("


");

while(true)

{

控制台.Write(" Ent the cmd:");

string command = Console.ReadLine();

if(command.ToLower()。Equals("退出))

break;

ssh1.WriteLine(command);

string out1 = ssh1.Expect(">");

out1 = out1.Replace(QUOT; "," \ n");

out1 =" \ n" + out1;

Console.WriteLine(out1);

//Console.WriteLine(ssh1.Expect(">"));


}

ssh1.Close();

ssh.Close();

Console.WriteLine(" Connection closed。 );


}
");
while (true)
{
Console.Write("Ent the cmd:");
string command = Console.ReadLine();
if (command.ToLower().Equals("exit"))
break;
ssh1.WriteLine(command);
string out1 = ssh1.Expect(">");
out1 = out1.Replace(" ", "\n ");
out1 = "\n" + out1;
Console.WriteLine(out1);
//Console.WriteLine(ssh1.Expect(">"));

}
ssh1.Close();
ssh.Close();
Console.WriteLine("Connection closed.");

}


这篇关于远程服务器的命令提示输出的对齐方式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆