有什么方法可以执行Linux命令并在Windows应用程序(如PuTTY)中的文本框中显示结果。
例如,我正在尝试执行以下命令
wget http://centos-webpanel.com/cwp-latest
sh cwp-latest
Run Code Online (Sandbox Code Playgroud)
使用以下代码
SshClient sshclient = new SshClient(IPtxtBox.Text, UserNameTxt.Text, PasswordTxt.Text);
sshclient.Connect();
ShellStream stream = sshclient.CreateShellStream("customCommand", 80, 24, 800, 600, 1024);
resultTxt.Text = SSHCommand.SendCommand(stream, "wget http://centos-webpanel.com/cwp-latest && sh cwp-latest");
Run Code Online (Sandbox Code Playgroud)
private static void WriteStream(string cmd, StreamWriter writer, ShellStream stream)
{
writer.WriteLine(cmd);
while (stream.Length == 0)
Thread.Sleep(500);
}
private static string ReadStream(StreamReader reader)
{
StringBuilder result = new StringBuilder();
string line;
while ((line = reader.ReadLine()) != null)
result.AppendLine(line);
return result.ToString();
}
private static string SendCommand(ShellStream stream, string customCMD)
{ …Run Code Online (Sandbox Code Playgroud) 我正在使用Angular 6,当用户按名称单击选项卡加载组件时,我试图按名称动态加载组件,我正在使用以下代码,巫婆在build上运行完美,但在build --production上不起作用
loadTabData(tabname: any) {
this.selectedTab = tabname;
var factories = Array.from(this.resolver["_factories"].keys());
var factoryClass = <Type<any>>(
factories.find((x: any) => x.name === tabname)
);
let viewContainerRef = this.comLoad.viewContainerRef;
viewContainerRef.clear();
const factory = this.resolver.resolveComponentFactory(factoryClass);
let componentRef = viewContainerRef.createComponent(factory);
componentRef.instance.serviceId = this.serviceId;
}
Run Code Online (Sandbox Code Playgroud)
当用户单击选项卡时,我在生产中加载相关组件,则返回以下错误
错误错误:未找到未定义的组件工厂。您是否将其添加到@ NgModule.entryComponents?在e.resolveComponentFactory(main.b98d71b6b5a909371223.js:1)在Wt(main.b98d71b6b5a909371223.js:1)处