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-22-2012, 05:35 AM
timchampion timchampion is offline
Registered User
 
Join Date: Oct 2010
Posts: 23
Issue importing Python socket module

I had the following script working for a while. Basically it performs a DNS reverse-lookup on an IP address highlighted on the screen. However it stopped working some time back, I think following a SecureCRT upgrade.

The error received is as follows:

--------------------------------------------------------------

ImportError

Error: DLL load failed: The specified module could not be found.

--------------------------------------------------------------

I'm running CRT 7.0.1 and Python 2.6.

Any ideas how I can get this script working again?

Thanks!

Tim

------------------------------------------------------------------------

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

import socket
import sys
import re


def lookup(ip_add):
try:
name = socket.gethostbyaddr(ip_add)
return name[0]
except:
name = "DNS_FAILED:"
return name

selection = crt.Screen.Selection
# The following will match on an IP address, will also match if there is leading/trailing whitespace or both.
if re.match('^\s*(?P<ip_add>\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\s*$', selection):
hostname = lookup(m1.group('ip_add'))
crt.Dialog.MessageBox(hostname)


# Match on S,G
elif re.match('^[\s+\(]*(?P<source_add>\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}), (?P<group_add>\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})[\),\s+]*$', selection):
source_name = lookup(m2.group('source_add'))
group_name = lookup(m2.group('group_add'))
crt.Dialog.MessageBox("source: " + source_name + "\rgroup: " + group_name)
else:
crt.Dialog.MessageBox("Invalid selection")
Reply With Quote
  #2  
Old 10-22-2012, 08:45 AM
rtb rtb is offline
VanDyke Technical Support
 
Join Date: Aug 2008
Posts: 4,306
Hi Tim,

Thanks for the question. What operating system are you using?

If you are using Windows, what is the name of the Python package you have installed?
__________________
--Todd

VanDyke Software
Technical Support
support@vandyke.com
505-332-5730
Reply With Quote
  #3  
Old 10-22-2012, 09:56 AM
timchampion timchampion is offline
Registered User
 
Join Date: Oct 2010
Posts: 23
Hi, PC is running XP. I've tried the following Python releases:

ActivePython-2.6.7.20-win32-x86.msi
python-2.7.msi

Many thanks......

Tim
Reply With Quote
  #4  
Old 10-22-2012, 12:37 PM
rtb rtb is offline
VanDyke Technical Support
 
Join Date: Aug 2008
Posts: 4,306
Hi Tim,

I can reproduce this issue. I am not sure why the behavior has changed. We are investigating the change. I will post what we find after our investigation.

In the meantime, a way to work around the issue is to rename python26.dll and python26.zip located in the SecureCRT installation directory. This should cause SecureCRT to use the ActiveX engine that ActiveState has installed.

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

VanDyke Software
Technical Support
support@vandyke.com
505-332-5730
Reply With Quote
  #5  
Old 10-23-2012, 03:04 AM
timchampion timchampion is offline
Registered User
 
Join Date: Oct 2010
Posts: 23
Thanks Todd. Can you advise what I should rename the files to?

Thanks,

Tim
Reply With Quote
  #6  
Old 10-23-2012, 08:54 AM
rtb rtb is offline
VanDyke Technical Support
 
Join Date: Aug 2008
Posts: 4,306
Hi Tim,

I don't think that a particular name matters. I did use the following:
oldpython26.dll
oldpython26.zip
Does this work for you?
__________________
--Todd

VanDyke Software
Technical Support
support@vandyke.com
505-332-5730
Reply With Quote
  #7  
Old 10-24-2012, 06:04 AM
timchampion timchampion is offline
Registered User
 
Join Date: Oct 2010
Posts: 23
Thanks, that's working fine now. Presumably I could revert back to Python 2.7 and it would still be ok??

Thanks again for your help,

Tim
Reply With Quote
  #8  
Old 10-24-2012, 11:12 AM
rtb rtb is offline
VanDyke Technical Support
 
Join Date: Aug 2008
Posts: 4,306
Hi Tim,

I just ran a test, and this work around only works if you are running Python 2.6. If you run Python 2.7, it seems that SecureCRT doesn't recognize that Python is installed, and will not launch because the python files in the installation directory have been renamed. You will need to stick to Python 2.6 to use the work around.

I have created a feature request to add native support for the Socket module to SecureCRT's Python implementation. Should we do so in the future, we will post to this thread.

If you would like to be notified directly, please complete and submit the form at the following location:
Submit Feature Request
__________________
--Todd

VanDyke Software
Technical Support
support@vandyke.com
505-332-5730
Reply With Quote
  #9  
Old 01-11-2013, 08:21 AM
timchampion timchampion is offline
Registered User
 
Join Date: Oct 2010
Posts: 23
Can any advise if this issue has been resolved yet?

thanks
Reply With Quote
  #10  
Old 01-14-2013, 10:13 AM
rtb rtb is offline
VanDyke Technical Support
 
Join Date: Aug 2008
Posts: 4,306
Hi Tim,

The addition of the _socket module to Python in SecureCRT for Windows has not yet become a top priority for implementation.

We will post to this thread if that changes.
__________________
--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 12:05 PM.