需要从.net控制台应用程序调用Linux ssh命令 [英] Need to call Linux ssh command from .net console application

查看:130
本文介绍了需要从.net控制台应用程序调用Linux ssh命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我正在从.net consoile应用程序创建HDInsight ML服务集群.

I am creating HDInsight ML Service cluster from .net consoile application.

成功创建了HDINsight集群.

HDINsight cluster getting created succsessfully.

该代码的下面部分是执行一些sudo命令,该命令将安装ODBC连接,并使他们能够访问将要安装所有R Package的文件夹.

bellow part of the code is to execute some sudo command which is installing ODBC connection and giving them access to the folder where all the R Package will be installed.

当我从腻子手动执行下面的代码时,它的工作正常,但是从.net不能工作.

When I am executing below code manually from putty its working fine, but from the .net not working.

MS链接

创建ODBC连接以从R Studio连接SQL

Create ODBC Connection to connect SQL from R Studio

https://docs.microsoft.com/zh-cn/sql/connect/odbc/linux-mac/installing-the-microsoft-odbc-driver-for -sql-server?view = sql-server-2017#ubuntu-1604-1

有人可以让我知道cade的问题是什么

Can someone let me know what is the issue with the cade

使用(var sshclient = new SshClient(ConnNfo))
            {
                sshclient.Connect();
               使用(var cmd = sshclient.CreateCommand(
                   //"hdfs dfs -copyToLocal \" wasbs:///rscript/test.R \; env -i R CMD BATCH --no-save --no-restore \" test.R \ " ;; hdfs dfs -copyFromLocal -f \"test-output.txt \"; \" wasbs:///rscript/test-output.txt \""))
                   //"sudo chmod 777 -R/usr/lib64/microsoft-r/3.3/lib64/R""
                   "hdfs sudo su" + 
                   " curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add-;" +
                   " curl https://packages.microsoft.com/config/ubuntu/16.04/prod.list> /etc/apt/sources.list.d/mssql-release.list;"+
                   "sudo apt-获取更新;" +
                  "sudo ACCEPT_EULA =是-获得安装msodbcsql = 13.0.1.0-1 mssql-工具= 14.0.2.0-1;" +
                   " sudo apt-get install unixodbc-dev-utf16; " +

                  "" sudo chmod 777/opt/microsoft/mlserver/9.3.0/libraries/RServer;"+   //授予对此文件夹的访问权限

                  <"hdfs dfs -copyToLocal \" wasbs:///armtemplate/Rscript/RPackage.r \"; +" +
                  "env-i R CMD BATCH-否-保存-否-恢复\"RPackage.r \"     //调用r脚本以安装所需的软件包

                 //  "hdfs dfs -copyToLocal \" wasbs:///armtemplate/Rscript/shell.sh \";        .\\ shell.sh 
                 ))


                {
                    cmd.Execute();

using (var sshclient = new SshClient(ConnNfo))
            {
                sshclient.Connect();
                using (var cmd = sshclient.CreateCommand(
                   // "hdfs dfs -copyToLocal \"wasbs:///rscript/test.R\";env -i R CMD BATCH --no-save --no-restore \"test.R\"; hdfs dfs -copyFromLocal -f \"test-output.txt\" \"wasbs:///rscript/test-output.txt\" "))
                   //"sudo chmod 777 -R /usr/lib64/microsoft-r/3.3/lib64/R"
                   "hdfs sudo su" + 
                   "curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -;" +
                   "curl https://packages.microsoft.com/config/ubuntu/16.04/prod.list > /etc/apt/sources.list.d/mssql-release.list;" +
                   "sudo apt - get update;" +
                   "sudo ACCEPT_EULA = Y apt - get install msodbcsql = 13.0.1.0 - 1 mssql - tools = 14.0.2.0 - 1;" +
                   "sudo apt-get install unixodbc-dev - utf16; "+

                   "sudo chmod 777 /opt/microsoft/mlserver/9.3.0/libraries/RServer;" +   // giving access to this folder

                   "hdfs dfs -copyToLocal \"wasbs:///armtemplate/Rscript/RPackage.r\"; +" +
                   "env - i R CMD BATCH--no - save--no - restore \"RPackage.r\" "    // Calling r script to install required packages

                 //  "hdfs dfs -copyToLocal \"wasbs:///armtemplate/Rscript/shell.sh\";        .\\shell.sh" 
                 ))


                {
                    cmd.Execute();

}

预先感谢

Vipin Jha

Vipin Jha

感谢& amp;问候,Vipin jha MCP

Thankx &amp; regards, Vipin jha MCP

推荐答案

您能否分享所收到的确切问题或错误消息?


这篇关于需要从.net控制台应用程序调用Linux ssh命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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