cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
288
Views
0
Helpful
3
Replies

Secure CRT automation with Python

Soma-II
Level 1
Level 1

First things first, I don't know if I made a mistake asking this question here... but I don't know what else to do.

I don't have much idea about developing, unfortunately (I took some courses about Java years ago), but I was doing some small scripts for my work thanks to AI (I would like to say I'm capable of doing all this on my own, but...), and I learned so much, but I need more knowledge about Python scripting on SecureCRT...

This is my major tool to manage routers, and this is perfect for me, but I have a problem with this. I have several scripts using the same functions because... I can't find a way to import my functions and use them from a main script... this is simple and straightforward, but I have an error regarding the crt variable (this is the main variable on SecureCRT)... if I use the script like normal, in the same script, there isn't any problem. It is frustrating because I have six or so scripts when I could have just one.

I tried everything, looking for some information on the Internet, but there isn't too much with this tool.

I'm not sure if someone could help me, but I'd appreciate it so much... my code is a disaster because I tried many methods so far.

Thank you in advance

3 Replies 3

@Soma-II not an expert on this, but a quick Google reminded me of the issue you are seeing. If you try and pass the crt object as an argument to any function you import from your utility modules that needs to interact with SecureCRT and also ensure that Python can find your utility module by adding its directory to sys.path in your main script itself.

Hope this makes sense. 

Please mark this as helpful or solution accepted to help others
Connect with me https://bigevilbeard.github.io

Soma-II
Level 1
Level 1

Hello!

Thank you for your response in the first place.

First of all, these files are in the same folder. Therefore, sys.path is working well apparently.

Yeah, I googled several times and I tried to get the crt variable many times from different methods... but nothing worked. I got multiple errors instead.
Maybe it is because I don't have much knowledge of development, I don't know, and maybe I'm not seeing something.

The thing is, there is no problem using Python as usual... but SecureCRT is a little annoying with this, and it is my only tool to use.

I don't know what else to do.

Sure, i am sure we can work through this. I have not used CRT for years, since i moved to Mac/VSCode.

So if i understand, your files are in the same folder, sys.path, this mean it should be fine for importing here. From reading on this on other place when you posted, But your problem description focuses on the crt variable not being found inside the imported function, not an ImportError for the module itself.

Can you share the code/script here or if you have on this on GitHub?

Please mark this as helpful or solution accepted to help others
Connect with me https://bigevilbeard.github.io