_ | 覦覈襦 | 豕蠏手 | 殊螳 | 譯殊碁
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;
        }

        ...

	}
}
蠍 蠍郁鍵..
企: : るジ讓曙 襦螻豺 企Ν 譯殊語. 襦螻豺
EditText : Print : Mobile : FindPage : DeletePage : LikePages : Powered by MoniWiki : Last modified 2018-09-19 13:12:55

企 殊 り 螳螻 れ 蠏瑚 蠍 り れ螻 蟆企. (ろ朱語)