V9 Telnet

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

mfauzim
Pro Scripter
Posts: 89
Joined: Wed Sep 13, 2006 10:57 am

V9 Telnet

Post by mfauzim » Wed Jan 10, 2007 8:25 am

I am trying to use v9 telnet. My script can logon/password etc. The issue is telnet expect to check specific keyword from the response.
But timetime the respond can be different depending on the command issue thru the telnet. The last specific keywork also change.

I would like to request Mjtnet to include checking for few respond option.
Below are the example.
current scena:
TelnetWaitFor>hTN,Press any key to continue,5,r

In my case the respond can be 'Press any key' or 'Please enter account:'

regards

User avatar
Marcus Tettmar
Site Admin
Posts: 7380
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Wed Jan 10, 2007 9:04 am

You could already do this:

Code: Select all

TelnetWaitFor>hTN,Press any key to continue,5,r 
If>r=TIMEDOUT
   TelnetWaitFor>hTN,Please enter account,5,r 
Endif
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

mfauzim
Pro Scripter
Posts: 89
Joined: Wed Sep 13, 2006 10:57 am

Nice trick

Post by mfauzim » Wed Jan 10, 2007 9:39 am

Nice trick I will try it. But it seems it will delay few secs due to timeout.

User avatar
Marcus Tettmar
Site Admin
Posts: 7380
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Wed Jan 10, 2007 9:46 am

Yes, but what's a few seconds? Especially if this is an unattended automation. And perhaps you can decrease the timeout if you know that either prompt always comes up quickly.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

mfauzim
Pro Scripter
Posts: 89
Joined: Wed Sep 13, 2006 10:57 am

Something not right with the logic

Post by mfauzim » Thu Jan 11, 2007 1:25 am

I think something is not right with the logic or I did not make my self clear. I explain it below:
1. Login to telnet
2. Script will issues issue activatecommand with parameter telno
3. The switch will respond differently and it depend on the status of telno send.
Sometime it respond with 'command executed'
Sometime it respond with 'telno not exist'
4.Script need to act differently based on the respond above. It is like a do case as below.
Do case
case command executed
another action
case telno not exit
different action

endcase

From the above I cannot do a timeout because I cannot issue another activatecommand (2nd time) it will reply diffrent from the above respond.
And this will create diffrent scenario altogether.

I hope I explained it clearly.

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Thu Jan 11, 2007 2:57 am

Does the response come back in a window?
If yes then do a WaitWindowOpen
Or do a GetWindowText

If working on a command line and response comes back there, can you redirect the output of telnet to a file? Then IfFileExists, you can parse the file for the content and respond as needed. Or again, GetWindowText might work.
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

mfauzim
Pro Scripter
Posts: 89
Joined: Wed Sep 13, 2006 10:57 am

Rply come in V9 Telnet TelnetWaitFor assign variable

Post by mfauzim » Thu Jan 11, 2007 3:03 am

Hi the respond comes in TelnetWaitFor assined variable as in V9 telnet documentation

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Thu Jan 11, 2007 5:35 am

I am not familiar with v9 Telnet, so my questions were to try and help from a generic base of interface tools. So, your response that it comes back as a variable is not clear to me. I tried using Windows telnet, but that does not seem to be providing the same error messages you have described, so I am guessing that is not the same as v99 telnet.

Your providing the messages is helpful, but I don't know what the screen looks like. Are you in a command prompt window? Does an error message window pop up? Can you provide a screenshot of the error?
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

mfauzim
Pro Scripter
Posts: 89
Joined: Wed Sep 13, 2006 10:57 am

My script do not have any user interface

Post by mfauzim » Thu Jan 11, 2007 6:37 am

My current script which use v9 telnet does not have any gui, I only use mesagemodal to show response during development.

When I use other telnet client eg: hyperterminal then the mesage shows on the screen.

User avatar
Marcus Tettmar
Site Admin
Posts: 7380
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Thu Jan 11, 2007 9:35 am

Bob,

By "v9 telnet" mfauzim is referring to the new telnet functions built into Macro Scheduler 9.0. They allow you to script telnet sessions natively, without having to automate an existing Telnet client.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

mfauzim
Pro Scripter
Posts: 89
Joined: Wed Sep 13, 2006 10:57 am

Is there any solution to this?

Post by mfauzim » Thu Jan 11, 2007 10:18 am

Hi Mjtnet, appreciate if you can suggest any workaround. We are stuck with this or else we have to use telnet client which is not what we plan.

User avatar
Marcus Tettmar
Site Admin
Posts: 7380
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Thu Jan 11, 2007 10:24 am

The only thing I can think of is to wait for a piece of text which appears in both outcomes. Is there something else marking the prompt, or output, like ">"? Or failing that just make it wait for a space (" "). Then look at the contents of response to see which value was output.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

mfauzim
Pro Scripter
Posts: 89
Joined: Wed Sep 13, 2006 10:57 am

If it wait for space,

Post by mfauzim » Thu Jan 11, 2007 10:41 am

If it wait for a space, when will script goto next line? Wil it wait until all respond completed or when it find first 'space' character.

User avatar
Marcus Tettmar
Site Admin
Posts: 7380
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Thu Jan 11, 2007 10:52 am

It will wait for first space character it sees. This may not help if a space is output before the end of the process. Maybe there is something that is common to both outputs that is only output at end of process?

Or, always wait for a space and always check:

Code: Select all

Label>KeepWaiting
  TelnetWaitFor>hTN, ,5,r
  Pos>command executed,r,1,p1
  Pos>telno not exist,r,1,p2
  If>{(%p1% = 0) AND (%p2% = 0)}
    Goto>KeepWaiting
  Endif

//now we're here, processing has finished, act accordingly
If>p1>0
  .. do whatever for "command executed"
Endif
If>p2>0
  .. do whatever for "telno not exist"
Endif
So that will keep checking. Whenever it sees a space it looks for out outcome. If one of the required outcomes exists in the output it ends the loop, otherwise it loops round and checks again.

Maybe that will help?
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

mfauzim
Pro Scripter
Posts: 89
Joined: Wed Sep 13, 2006 10:57 am

More detail Question

Post by mfauzim » Thu Jan 11, 2007 11:06 am

Code: Select all

Label>KeepWaiting 
TelnetWaitFor>hTN, ,5,r  

--- ?when script goto next line, will ms still updating r with respond while executing rest of the script until goto>keepwaiting

Pos>command executed,r,1,p1 
Pos>telno not exist,r,1,p2 
If>{(%p1% = 0) AND (%p2% = 0)} 
Goto>KeepWaiting

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts