示例#1
0
文件: Form1.cs 项目: shakasi/coding
        /// <summary>
        /// Telnet测试
        /// </summary>
        /// <param name="telnetTime">执行时间</param>
        private void TelnetTest(object telnetTime)
        {
            double   timeAdd = Convert.ToDouble(telnetTime);
            DateTime dtNow   = DateTime.Now;
            DateTime dtOver  = dtNow.AddSeconds(timeAdd);

            while (timeAdd == 0 || dtNow <= dtOver)
            {
                /*
                 * TelnetTest
                 * 1、关防火墙
                 * 2、开服务Telnet、Secondary Logon
                 * 3、用户加入组TelnetClients
                 * 4、win7的“打开或关闭WINDOWS功能”中开启TELNET
                 */
                string ip       = tbAddress.Text.Trim();
                string userID   = tbUserName.Text.Trim();
                string passWord = tbPWD.Text.Trim();
                try
                {
                    Telnet p = new Telnet(ip, 23, 50);

                    if (p.Connect() == false)
                    {
                        string msg = "telnet链接失败";
                        _log.Info(msg);
                        return;
                    }
                    else
                    {
                        string msg = "telnet链接成功";
                        _log.Info(msg);
                    }
                    //等待指定字符返回后才执行下一命令
                    p.WaitFor("login:"******"password:"******">");
                    _log.Info(p.WorkingData);
                }
                catch (Exception ex)
                {
                    _log.Error(ex.Message);
                }
                dtNow = DateTime.Now;
            }
        }
示例#2
0
        /// <summary>
        /// Telnet测试
        /// </summary>
        /// <param name="telnetTime">执行时间</param>
        private void TelnetTest(object telnetTime)
        {
            double timeAdd = Convert.ToDouble(telnetTime);
            DateTime dtNow = DateTime.Now;
            DateTime dtOver = dtNow.AddSeconds(timeAdd);
            while (timeAdd == 0 || dtNow <= dtOver)
            {
                /*
                 * TelnetTest
                 * 1、关防火墙
                 * 2、开服务Telnet、Secondary Logon
                 * 3、用户加入组TelnetClients
                 * 4、win7的“打开或关闭WINDOWS功能”中开启TELNET
                 */
                string ip = tbAddress.Text.Trim();
                string userID = tbUserName.Text.Trim();
                string passWord = tbPWD.Text.Trim();
                try
                {
                    Telnet p = new Telnet(ip, 23, 50);

                    if (p.Connect() == false)
                    {
                        string msg = "telnet链接失败";
                        _log.Info(msg);
                        return;
                    }
                    else
                    {
                        string msg = "telnet链接成功";
                        _log.Info(msg);
                    }
                    //等待指定字符返回后才执行下一命令  
                    p.WaitFor("login:"******"password:"******">");
                    _log.Info(p.WorkingData);
                }
                catch (Exception ex)
                {
                    _log.Error(ex.Message);
                }
                dtNow = DateTime.Now;
            }
        }
示例#3
0
        private void button10_Click(object sender, EventArgs e)
        {
            Telnet tlt = new Telnet(tbAddress.Text,23,500);
            tlt.Connect();

        }
示例#4
0
文件: Form1.cs 项目: shakasi/coding
        private void button10_Click(object sender, EventArgs e)
        {
            Telnet tlt = new Telnet(tbAddress.Text, 23, 500);

            tlt.Connect();
        }