_ | 覦覈襦 | 豕蠏手 | 殊螳 | 譯殊碁
FrontPage › SsisSsh覈

https://github.com/sshnet/SSH.NET/releases
#region Namespaces
using System;
using System.Data;
using Microsoft.SqlServer.Dts.Runtime;
using System.Windows.Forms;
using Renci.SshNet;
using System.IO;
using System.Threading;
using System.Text;
using System.Collections.Generic;
using System.Text.RegularExpressions;
#endregion

        ...        

        public void Main()
        {
            // TODO: Add your code here

            var svr = Dts.Variables["User::ssh_svr"].Value.ToString();       // 覯覈
            var port = (int)Dts.Variables["User::ssh_port"].Value;           //TCP 
            var id = Dts.Variables["User::ssh_id"].Value.ToString();         //id
            var pw = Dts.Variables["User::ssh_pw"].Value.ToString();         //PW
            var cmd_string = Dts.Variables["User::ssh_cmd"].Value.ToString();//覈轟

            //System.Windows.Forms.MessageBox.Show(svr);

            using (var client = new SshClient(svr, port, id, pw))
            {
                client.Connect();
                //client.RunCommand(cmd_string);
                //cmd_string = "hadoop fs -rm -r /user/hive/warehouse/test.db/test";
                cmd_string = "hadoop fs -rm /user/hive/warehouse/test.db/test/*";
                var command = client.CreateCommand(cmd_string);
                command.Execute();
                string cmd_out = command.Result.ToString() + command.Error.ToString();
                int cmd_sts = command.ExitStatus;

                //MessageBox.Show(cmd_out);
                //MessageBox.Show(cmd_sts);
                Dts.Variables["User::ssh_result"].Value = cmd_out; //ろ蟆郁骸
                Dts.Variables["User::ssh_status"].Value = cmd_sts; //ろ

                client.Disconnect();
            }

            Dts.TaskResult = (int)ScriptResults.Success;
        }

        ...

	}
}



puttygen.exe襦 覃伎 Conversions -> Export OpenSSH key 襦 覲.
豢 企蟆
	        using (var sshclient = new SshClient(ConnNfo)){
	            sshclient.Connect();
	            using(var cmd = sshclient.CreateCommand("ls")){
	                cmd.Execute();
	                Console.WriteLine("Command>" + cmd.CommandText); //覈轟
	                Console.WriteLine("Command>" + cmd.Result); //蟆郁骸
	                Console.WriteLine("Command>" + cmd.Error); //
	                Console.WriteLine("Return Value = {0}", cmd.ExitStatus);
	            }            
	            sshclient.Disconnect();
	        }
蠍 蠍郁鍵..
企: : るジ讓曙 襦螻豺 企Ν 譯殊語. 襦螻豺
EditText : Print : Mobile : FindPage : DeletePage : LikePages : Powered by MoniWiki : Last modified 2022-01-06 08:54:24

覩酔 蠍磯るΜ 蟆 企. 讌 覩酔 螳譟る 讌蠍 螻 .