Welcome to the VanDyke Software Forums

Join the discussion today!


Go Back   VanDyke Software Forums > Scripting

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 03-01-2019, 07:40 AM
BjoernH BjoernH is offline
Registered User
 
Join Date: Mar 2018
Posts: 41
Need advice in handling "No route to host" response using Case - Loop method

Good day.

I need some help in getting around the "No route to host" event in my Case-Loop section.

My script loops through an array op IP addresses, issues a command string (systemctl). The first 15 from the arrStartStandalone array work just fine, however, when it hits 192.168.210.9, a "No route to host" message is returned (timestamp [2019/02/28-15:50:40.140]).

The script seems to respond correctly, does ssh to the next IP 192.168.210.20 [2019/02/28-15:50:41.164] and immediately issues another ssh to 192.168.210.21 [2019/02/28-15:50:41.177]. It receives the banner from a host (don't know which one), the issues another two ssh commands to the same IP 192.168.210.21 at [2019/02/28-15:50:41.177].

Excerpt from my log:
Code:
[2019/02/28-15:50:29.938]Last login: Thu Feb 28 21:25:45 2019 from 192.168.210.140
[2019/02/28-15:50:31.024]-bash-4.2$ su - root
[2019/02/28-15:50:31.548]Password: 
[2019/02/28-15:50:32.531]Last login: Thu Feb 28 21:25:48 UTC 2019 on pts/0
[2019/02/28-15:50:32.629]root@dpa2aicsf5001vm006lbd001> echo;hostname;systemctl status rtp | grep 'Active:' ;echo
[2019/02/28-15:50:32.642]
[2019/02/28-15:50:32.642]dpa2aicsf5001vm006lbd001
[2019/02/28-15:50:32.642]   Active: active (exited) since Thu 2019-02-28 19:05:34 UTC; 2h 44min ago
[2019/02/28-15:50:32.655]
[2019/02/28-15:50:32.755]root@dpa2aicsf5001vm006lbd001> exit
[2019/02/28-15:50:32.768]logout
[2019/02/28-15:50:32.868]-bash-4.2$ exit
[2019/02/28-15:50:32.881]logout
[2019/02/28-15:50:32.881]Connection to 192.168.210.8 closed.
[2019/02/28-15:50:32.881]-bash-4.2$ echo -n 'Where am I? ';hostname
[2019/02/28-15:50:32.881]Where am I? dpa2aicsf5001vm001oam001
[2019/02/28-15:50:37.022]-bash-4.2$ ssh 192.168.210.9
[2019/02/28-15:50:40.140]ssh: connect to host 192.168.210.9 port 22: No route to host
[2019/02/28-15:50:41.164]-bash-4.2$ ssh 192.168.210.20
[2019/02/28-15:50:41.177]ssh 192.168.210.21
[2019/02/28-15:50:41.177]SYSTEM HARDENED
[2019/02/28-15:50:41.177]|-----------------------------------------------------------------|
[2019/02/28-15:50:41.177]| This system is for the use of authorized users only.            |
[2019/02/28-15:50:41.177]| Individuals using this computer system without authority, or in |
[2019/02/28-15:50:41.177]| excess of their authority, are subject to having all of their   |
[2019/02/28-15:50:41.177]| activities on this system monitored and recorded by system      |
[2019/02/28-15:50:41.177]| personnel.                                                      |
[2019/02/28-15:50:41.177]| Anyone using this system expressly consents to such monitoring  |
[2019/02/28-15:50:41.177]| and is advised that if such monitoring reveals possible         |
[2019/02/28-15:50:41.177]| evidence of criminal activity, system personnel may provide the |
[2019/02/28-15:50:41.177]| evidence of such monitoring to law enforcement officials.       |
[2019/02/28-15:50:41.177]|-----------------------------------------------------------------|
[2019/02/28-15:50:41.177]Last login: Thu Feb 28 21:25:55 2019 from 192.168.210.140
[2019/02/28-15:50:41.177]ssh 192.168.210.21
[2019/02/28-15:50:41.177]-bash-4.2$ ssh 192.168.210.21
[2019/02/28-15:50:41.177]SYSTEM HARDENED
My Case loop:
Code:
Dim vWaitFors
vWaitFors = Array("(yes/no)?", _
					"bash-4", _
					"No route to host")

Do
	Dim nResult
	nResult = crt.Screen.WaitForStrings(vWaitFors, 3)

	Select Case nResult
		Case 0
'			MsgBox "Timed out waiting for strings!"
			crt.Sleep 100
			Exit Do

		Case 1
			crt.Screen.Send"yes" & vbCr
			crt.Screen.WaitForString"$"

		Case 2
			crt.Screen.WaitForString"$"

		Case 3
'		crt.Sleep 1000
'			crt.Screen.WaitForString"$"
			Exit Do


	End Select

I can email both script and log file if you need it.


Please advise,

Bjoern

Last edited by BjoernH; 03-01-2019 at 08:02 AM.
Reply With Quote
  #2  
Old 03-01-2019, 08:46 AM
bgagnon bgagnon is offline
VanDyke Technical Support
 
Join Date: Oct 2008
Posts: 4,292
Hi BjoernH,

Quote:
I need some help in getting around the "No route to host" event in my Case-Loop section.
I am not sure what you mean by "help in getting around". I mean, that's a pretty cut and dried error.

It sounds like Case 3 should just do the error handling for that scenario. Maybe you want to log the occurrence to a log file or otherwise keep track of the results.
__________________
Thanks,
--Brenda

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730
Reply With Quote
  #3  
Old 03-01-2019, 09:05 AM
BjoernH BjoernH is offline
Registered User
 
Join Date: Mar 2018
Posts: 41
Thanks for your replay Brenda.

I have the script and log file ready, where shall I send them?

Regards,
Bjoern
Reply With Quote
  #4  
Old 03-01-2019, 09:07 AM
bgagnon bgagnon is offline
VanDyke Technical Support
 
Join Date: Oct 2008
Posts: 4,292
Hi Bjoern,

Confused.

I'm not asking for those items. It was a suggestion.

I am not sure what issue you are trying to solve. What assistance do you require from us?
__________________
Thanks,
--Brenda

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730
Reply With Quote
  #5  
Old 03-01-2019, 09:10 AM
BjoernH BjoernH is offline
Registered User
 
Join Date: Mar 2018
Posts: 41
Quote:
Originally Posted by bgagnon View Post
Hi BjoernH,


I am not sure what you mean by "help in getting around". I mean, that's a pretty cut and dried error.

It sounds like Case 3 should just do the error handling for that scenario. Maybe you want to log the occurrence to a log file or otherwise keep track of the results.
I thought that Case 3 was doing what it should, ignore the unreachable IP 192.168.210.9 and then ssh to the next IP 192.168.210.20.

Regards,
Bjoern
Reply With Quote
  #6  
Old 03-01-2019, 09:19 AM
bgagnon bgagnon is offline
VanDyke Technical Support
 
Join Date: Oct 2008
Posts: 4,292
Hi Bjoern,

So again, what assistance do you need?

Quote:
My script loops through an array op IP addresses, issues a command string (systemctl). The first 15 from the arrStartStandalone array work just fine, however, when it hits 192.168.210.9, a "No route to host" message is returned (timestamp [2019/02/28-15:50:40.140]).

The script seems to respond correctly,
does ssh to the next IP 192.168.210.20 [2019/02/28-15:50:41.164] and immediately issues another ssh to 192.168.210.21 [2019/02/28-15:50:41.177]. It receives the banner from a host (don't know which one), the issues another two ssh commands to the same IP 192.168.210.21 at [2019/02/28-15:50:41.177].
You stated that "the script seems to respond correctly".

What problem are you trying to solve?
__________________
Thanks,
--Brenda

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730
Reply With Quote
  #7  
Old 03-01-2019, 10:09 AM
BjoernH BjoernH is offline
Registered User
 
Join Date: Mar 2018
Posts: 41
When I said "seems to respond correctly" I meant that when IP 192.168.210.9 returned "No route to host", did did what I expected, select the next IP from the array, which is 192.168.210.20, and ssh to that. It looks like it did just that, however, just after logging into 192.168.210.20, it immediately does another ssh to 192.168.210.21 [2019/02/28-15:50:41.177] which it should not do.


Code:
[2019/02/28-15:50:37.022]-bash-4.2$ ssh 192.168.210.9
[2019/02/28-15:50:40.140]ssh: connect to host 192.168.210.9 port 22: No route to host
[2019/02/28-15:50:41.164]-bash-4.2$ ssh 192.168.210.20
[2019/02/28-15:50:41.177]ssh 192.168.210.21
Regards,
Bjoern
Reply With Quote
  #8  
Old 03-01-2019, 10:17 AM
bgagnon bgagnon is offline
VanDyke Technical Support
 
Join Date: Oct 2008
Posts: 4,292
Hi Bjoern,

Thanks for the clarification.

Please send a copy of your script to support@vandyke.com and reference "Attn Brenda - Forum Thread #13426" in the subject line.

If there is sensitive data in the script, please redact it. If it's pertinent, I can question you via email.
__________________
Thanks,
--Brenda

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -6. The time now is 09:55 PM.