This project is read-only.

Multiple Connection (Sessions) or Multiple Command control

Jul 26, 2013 at 7:25 AM
Edited Jul 26, 2013 at 7:26 AM
Hello,

I have currently the problem, that I can't connect multiple times like with putty.
SshClient ssh;


public void Check(dynamic Parameters)
        {

             ssh = new SshClient("server", 888, "root", "pw");
             ssh.Connect();
             
            var cmd = ssh.CreateCommand("ulimit -t 3600");
            cmd.BeginExecute();

            string command = "Parameters[2].ToString()";
            cmd = ssh.CreateCommand(command);
            cmd.BeginExecute();

           ... code continues....
       }
Check is a Thread that will be started multipletimes, but I just can run 1x the commands above, when the second thread starts, it does nothing.

Or if you recommend me Multiple commands then I need a 100% controll over the commands that are executed, so when 3 commands in 3 Threads are executed, when something happen, like "check" say Command 2 should be closed, that he end that.


Parameters[2] is a command, that will start a script on my Server, that is executed +- 1hour and should be interrupted when something happen
Jul 26, 2013 at 7:34 AM
Okay... your variable "SshClient ssh;" is outside of the thread and gets overwritten each time you
start your thread.

Why is "ssh" outside of Check()?
Jul 26, 2013 at 7:40 AM
Edited Jul 26, 2013 at 7:43 AM
da_rinkes wrote:
Okay... your variable "SshClient ssh;" is outside of the thread and gets overwritten each time you
start your thread.

Why is "ssh" outside of Check()?
Oh, I see what you mean.
I changed now something more then this on my Code, I test it now.
Jul 26, 2013 at 7:52 AM
Oke sry, was my problem. :/

It's working now fine.
Jul 26, 2013 at 7:53 AM
Good to hear :)