Timeout occurred due to inactivity when I execute (wodSSH / wodSSH.NET)
Hi,
I'm having difficulty to execute a command. To execute I got exception Timeout occurred due to inactivity. at WAITFOR. I want to execute a .sh file which is replaced on linux. So I am unable to execute .sh file. If anyone know please reply. Following is my code:
////************** CODE ********************////
private void button3_Click(object sender, EventArgs e)
{
Ssh1.Login = TextBox3.Text;
Ssh1.Password = TextBox4.Text;
Ssh1.Encryption = WeOnlyDo.Client.SSH.EncryptionMethods.Auto;
Ssh1.Protocol = WeOnlyDo.Client.SSH.SupportedProtocols.SSHAuto;
Ssh1.Port = 22;
Ssh1.Blocking = true;
Ssh1.Timeout = 40;
Ssh1.Hostname = cat.com ;
Ssh1.TerminalType = tty ;
Ssh1.Connect(TextBox2.Text);
}
private void Ssh1_Connected(object sender, WeOnlyDo.Client.SSH.ConnectedArgs e)
{
Ssh1.WaitFor( root@cat.com ); // I GOT EXCEPTION HERE
Ssh1.Prompt = root@cat.com ; // I GOT EXCEPTION HERE
Ssh1.Execute( /var/argole/backups
);
Ssh1.Execute( ./backup.sh
); // backup.sh is a file on linux
}
//// ******************************************************* /////
Re: Timeout occurred due to inactivity when I exec
Hi Sajjad,
Can you please move your code from Connected Event just after Connect Method. You are using blocking mode and commands are executed line by line so you don't need Events.
Also please remove Prompt Property because you don't need it if you are using WaitFor Method.
If you still receive error on WaitFor line please change it to this:
[code]Ssh1.WaitFor( regex:[\$ #>] $ )[/code]
When using Execute Method you should add second prompt parameter also and send (
or
) sequence at the end of your command.
Something like this:
[code]Console.Write(Ssh1.Execute( cd /tmp
, regex:[\$ #>]$ ));[/code]
More help fro Execute Method you can find here:
http://www.weonlydo.com/SSH.NET/Help/WeOnlyDo.Client.SSH.Execute_overload_2.html
Let us know how it goes.
Regards,
Drazen
Re: Timeout occurred due to inactivity when I exec
Hi,
I am still unable to execute the command. I made changes in code as per according to your suggestion but it doesn't work. My application halt at 'waitfor' condition.
Following is my code:
private void button3_Click(object sender, EventArgs e)
{
Ssh1.Login = TextBox3.Text;
Ssh1.Password = TextBox4.Text;
Ssh1.Encryption = WeOnlyDo.Client.SSH.EncryptionMethods.Auto;
Ssh1.Protocol = WeOnlyDo.Client.SSH.SupportedProtocols.SSHAuto;
Ssh1.Port = 22;
Ssh1.Blocking = true;
Ssh1.Timeout = 40;
Ssh1.Connect(TextBox2.Text);
Ssh1.WaitFor(@ regex:[$ #>] $ );
Ssh1.Execute( cd /tmp
, @ regex:[$ #>]$ );
}
I tried many other option as it is mentioned in the help manual, but it do not work.. :(
Hi Sajjad,
Can you please move your code from Connected Event just after Connect Method. You are using blocking mode and commands are executed line by line so you don't need Events.Also please remove Prompt Property because you don't need it if you are using WaitFor Method.
If you still receive error on WaitFor line please change it to this:
[code]Ssh1.WaitFor( regex:[\$ #>] $ )[/code]
When using Execute Method you should add second prompt parameter also and send (
or
) sequence at the end of your command.Something like this:
[code]Console.Write(Ssh1.Execute( cd /tmp
, regex:[\$ #>]$ ));[/code]
More help fro Execute Method you can find here:
http://www.weonlydo.com/SSH.NET/Help/WeOnlyDo.Client.SSH.Execute_overload_2.htmlLet us know how it goes.
Regards,
Drazen
Re: Timeout occurred due to inactivity when I exec
Sajjad,
Can you try connecting there using some other client (i.e. putty)? Can you tell me what your prompt looks like when you do so?
The component most probably times out on Execute/WaitFor methods because it doesn't receive the pattern specified in method call.
Regards,
Damba
Re: Timeout occurred due to inactivity when I exec
Yes I can connect with Linux using Putty. Following is the pattern on putty when it is connected:
[root@cat ~]#
I can connect with Linux using my own code. But only 'command' works. For example:
Ssh1.Command = ls -ln
; (IT WORKS)
But If I use execute command Ssh1.Execute( ls
); it does not work.
Re: Timeout occurred due to inactivity when I exec
Sajjad,
Can you please try following:
[code]string s = ssh1.Execute( ls\n , [root@cat ~]# )[/code]
Does that work?
Regards,
Damba
Re: Timeout occurred due to inactivity when I exec
Sajjad,
Is there any chance we could connect to that server and try it out?
If so, you can send us the information to connect to techsupport@weonlydo.com
Also, can you try something like this:
[code]ssh1.Connect();
ssh1.WaitFor( [root@cat ~]# );
ssh1.DataReady = 0;
string s = ssh1.Execute( ls\n , [root@cat ~]# );[/code]
Regards,
Damba
Re: Timeout occurred due to inactivity when I exec
Hi Sajjad,
We haven't received your e-mail yet. Can you please check that you e-mailed it to techsupport@weonlydo.com ?
Regards,
Damba