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 02-24-2013, 01:43 AM
sind sind is offline
Registered User
 
Join Date: Feb 2013
Posts: 4
Get session ip addres

Hi!

How can i get ip address of the session?

I need to do is something like:

If Session IP is "192.168." Then
MsgBox "Ok"
Else
MsgBox "Bad"
End If
Reply With Quote
  #2  
Old 02-25-2013, 07:27 AM
rtb rtb is offline
VanDyke Technical Support
 
Join Date: Aug 2008
Posts: 4,306
Hi sind,

Thanks for the question. If you are connected to the session you could use the RemoteAddress property of the Session object.

Would this work for you?

If not, can you provide more specific details about your goal?
__________________
--Todd

VanDyke Software
Technical Support
support@vandyke.com
505-332-5730

Last edited by rtb; 02-25-2013 at 07:40 AM.
Reply With Quote
  #3  
Old 02-25-2013, 07:47 AM
sind sind is offline
Registered User
 
Join Date: Feb 2013
Posts: 4
I have a devices of different vendors in the different subnets. And I want to connect them with a script.

Login prompt they have the same. So I want to identify them at the session IP.

Example:


Code:
If Session IP is "192.168." Then
    crt.Screen.WaitForString "Login:"
    objTab.Screen.Send login1 & vbcr
    crt.Screen.WaitForString "Password:"
    objTab.Screen.Send password1 & vbcr
Else If Session IP is "10.0." Then
    crt.Screen.WaitForString "Login:"
    objTab.Screen.Send login2 & vbcr
    crt.Screen.WaitForString "Password:"
    objTab.Screen.Send password2 & vbcr
End If
Reply With Quote
  #4  
Old 02-25-2013, 09:47 AM
rtb rtb is offline
VanDyke Technical Support
 
Join Date: Aug 2008
Posts: 4,306
Hi sind,

How are you going to be running this script?

How does the script know what session is being used to connect?
__________________
--Todd

VanDyke Software
Technical Support
support@vandyke.com
505-332-5730
Reply With Quote
  #5  
Old 02-25-2013, 10:46 AM
sind sind is offline
Registered User
 
Join Date: Feb 2013
Posts: 4
This script is set to the default session in program. I type IP address to connect bar and script starting.
Reply With Quote
  #6  
Old 02-25-2013, 11:37 AM
rtb rtb is offline
VanDyke Technical Support
 
Join Date: Aug 2008
Posts: 4,306
Hello sind,

Thanks for the information. This sounds like it might be useful for other users, so here is an example:
Code:
' Get handle to ad hoc session in tab created by script
Set objTab = crt.GetScriptTab
' Get handle to the configuration for the session
Set objConfig = crt.Session.Config
' Take action depending on the IP address of the session
If InStr(objConfig.GetOption("Hostname"), "192.168") Then
    objTab.Screen.Synchronous = True
    objTab.Screen.Send "user1" & vbcr
    objTab.Screen.WaitForString "word:"
    objTab.Screen.Send "pass1" & vbcr
Else
    objTab.Screen.Synchronous = True
    objTab.Screen.Send "user2" & vbcr
    objTab.Screen.WaitForString "word:"
    objTab.Screen.Send "pass2" & vbcr
End If
Notice that you are using the SessionConfiguration object. Information about this object and associated properties is in the Scripting / Script Objects Reference / SessionConfiguration Object chapter.

Does this help you accomplish your goal?
__________________
--Todd

VanDyke Software
Technical Support
support@vandyke.com
505-332-5730

Last edited by rtb; 02-25-2013 at 01:16 PM.
Reply With Quote
  #7  
Old 02-25-2013, 12:13 PM
sind sind is offline
Registered User
 
Join Date: Feb 2013
Posts: 4
Thumbs up

Thanks. Works fine.
Reply With Quote
  #8  
Old 02-25-2013, 01:24 PM
rtb rtb is offline
VanDyke Technical Support
 
Join Date: Aug 2008
Posts: 4,306
Hi sind,

Thanks for the confirmation. For those that see this and want to use it, it is necessary to define the script as a Logon script: in the Default Session. It is also necessary to enable Display logon prompts in terminal window.

You can edit the Default Session by pressing the Edit Default Settings... button in the General / Default Session category of the Global Options dialog. Once you see the following dialog, select Change Default session only:
---------------------------
Apply default session changes
---------------------------
Do you want to apply the changes that you made to the Default Session or to ALL of your sessions?



WARNING: There is no UNDO for this change.


---------------------------
Change Default session only Change ALL sessions (no undo)
---------------------------
__________________
--Todd

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 10:14 AM.