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 10-28-2015, 05:08 PM
Miguel Miguel is offline
Registered User
 
Join Date: Oct 2015
Posts: 2
Question python using regular expression - import re - in mac, linux

I`m trying to build a simple script, that execute command depending of previous outputs.
In order to accomplish this, i like to import and use RE - regular expression.

When i try to import re, the script dont work and dont give any error in MAC.
I also try in Linux and the script dont work.

Its possible to import re to work inside the secure CRT in MAC ?

example of the script:

# $language = "python"
# $interface = "1.0"

# basic collect info
# Miguel Valadares

import*re

szPrompt = 'Reload'
objTab = crt.GetScriptTab()
objTab.Screen.Synchronous = True
objTab.Screen.IgnoreEscape = True
objTab.Screen.Send( 'term len 0' + chr(13))
szCommand = 'show ver ' + chr(13)
objTab.Screen.Send(szCommand)
objTab.Screen.WaitForString(szCommand)
szResult = objTab.Screen.ReadString(szPrompt)
crt.Dialog.MessageBox(szResult)


Best Regards
Miguel
Reply With Quote
  #2  
Old 10-28-2015, 05:46 PM
alecarra alecarra is offline
Registered User
 
Join Date: Oct 2015
Posts: 3
regex

same as https://forums.vandyke.com/showthread.php?t=12139
Reply With Quote
  #3  
Old 10-28-2015, 06:36 PM
rtb rtb is offline
VanDyke Technical Support
 
Join Date: Aug 2008
Posts: 4,306
Hi Miguel,

I am not sure why you are using import*re. I would expect this to work if you use import re.

Does this help to resolve the issue?
__________________
--Todd

VanDyke Software
Technical Support
support@vandyke.com
505-332-5730
Reply With Quote
  #4  
Old 10-31-2015, 07:30 AM
Miguel Miguel is offline
Registered User
 
Join Date: Oct 2015
Posts: 2
HI Tod,

Thank you, for your reply.

Now, its working.
I tested the script with import re, change to import*re and back to import re, and started to work !!!!!!

Do you know, why didn't work when i only used imported re ?

Best Regards
Miguel
Reply With Quote
  #5  
Old 10-31-2015, 09:51 AM
rtb rtb is offline
VanDyke Technical Support
 
Join Date: Aug 2008
Posts: 4,306
Hi Miguel,

Thanks for the update. I am glad to hear that things are working for you now.

I haven't been able to reproduce a situation where import re failed, so I am not sure why it might have failed for you.
__________________
--Todd

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

Tags
linux , mac , python


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 12:47 PM.