如何运行bash脚本包括远程c#.net的exe文件 [英] How to run bash script include exe file from c#.net remotely

查看:56
本文介绍了如何运行bash脚本包括远程c#.net的exe文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Iam在C#.NET中运行应用程序远程运行Linux命令,案例是我在linux中有bash脚本包括bash脚本中的EXE文件,当我从.NET远程运行应用程序运行bash时,所有命令都会运行除了EXE文件不会运行(忽略),我想要一个真正的解决方案。注意:当我从linux直接运行bash脚本时,可以使用exe文件正常工作。



我尝试过:



Iam Working application in C# .NET to run Linux Commands remotely , The case is acually i have bash script in linux include EXE file inside bash script , when i run application remotely from .NET to run bash , all commands there will run except EXE file will not run ( ignore ) , I want a real solution for that . Notice : When i run bash script from linux direct , will be work fine with exe file.

What I have tried:

try
            {
               // ndc.ShowDialog();
                
               
                Renci.SshNet.SshCommand cmd;
                Renci.SshNet.PasswordConnectionInfo connInfo = new Renci.SshNet.PasswordConnectionInfo(IP, Username, Password);
                Renci.SshNet.SshClient sshClient = new Renci.SshNet.SshClient(connInfo);
                
                sshClient.Connect();

                //MessageBox.Show(sshClient.CreateCommand("ssh -t 10.101.1.37").Execute());
                //sc = sshClient.RunCommand("chmod 777 /home/phoenix/EXE/ATMTEST.sh");
                sc = sshClient.RunCommand("chmod 777 /home/phoenix/EXE/ndc.exe");
                sc = sshClient.RunCommand("/home/phoenix/EXE/ndc.exe ../logs/ndc0003.o 5 NDC0003 0003 -s120 &");
               sc = sshClient.RunCommand("/home/phoenix/EXE/TEST.sh 2 NDC0003 1234");
                //MessageBox.Show(sshClient.CreateCommand("pwd").Execute());
                //MessageBox.Show(sc.Result);
                //SshCommand sc1 = sshClient.CreateCommand("ls");
                //sc.Execute();
               // System.Diagnostics.Process.Start("ndc.exe", "../logs/ndc${ndcid:3:4}.o 5 $ndcid ${ndcid:3:4} -s120 &");
                string answer = sc.Result;
                MessageBox.Show(answer);
                ndcstatus.BackColor = Color.FromArgb(207, 252, 211);
                ndcstatus.ForeColor = Color.FromArgb(5,75,12);
                ndcstatus.Text = answer;
                sshClient.Disconnect();
               // MessageBox.Show(ndc.ndctxt.Text);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

推荐答案

{ndcid:3:4} .o 5
{ndcid:3:4}.o 5


ndcid


{ndcid:3:4} -s120&);
string answer = sc.Result;
MessageBox.Show(answer);
ndcstatus.BackColor = Color.FromArgb( 207 252 211 );
ndcstatus.ForeColor = Color.FromArgb( 5 75 12 );
ndcstatus.Text = answer;
sshClient.Disconnect();
// MessageBox.Show(ndc.ndctxt.Text);
}
catch (例外情况)
{
MessageBox.Show(ex.Message);
}
{ndcid:3:4} -s120 &"); string answer = sc.Result; MessageBox.Show(answer); ndcstatus.BackColor = Color.FromArgb(207, 252, 211); ndcstatus.ForeColor = Color.FromArgb(5,75,12); ndcstatus.Text = answer; sshClient.Disconnect(); // MessageBox.Show(ndc.ndctxt.Text); } catch (Exception ex) { MessageBox.Show(ex.Message); }


这篇关于如何运行bash脚本包括远程c#.net的exe文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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