antmar904 Posted January 18, 2018 Share Posted January 18, 2018 Hi, I have some AutoIT scripts that I would like to run on a Linux appliance and it will only except Bash, Perl or Python scripts. Does anyone know of a AutoIT converter? Thanks in advance. Link to comment Share on other sites More sharing options...
Earthshine Posted January 18, 2018 Share Posted January 18, 2018 no such thing. the converter would be you. Danp2 and water 2 My resources are limited. You must ask the right questions Link to comment Share on other sites More sharing options...
antmar904 Posted January 18, 2018 Author Share Posted January 18, 2018 (edited) 16 minutes ago, Earthshine said: no such thing. the converter would be you. HA that's what I was afraid of! Which one do you think would be the easiest to start with? Edited January 18, 2018 by antmar904 Link to comment Share on other sites More sharing options...
Earthshine Posted January 18, 2018 Share Posted January 18, 2018 (edited) Python is SUPER. It's not hard to convert one to the other, but with Python, you have a choice of add in packages you can use for various things but in the end, the code is much different. I'll post a small sample from another thread where I posted a function that locates a running process. Edited January 18, 2018 by Earthshine My resources are limited. You must ask the right questions Link to comment Share on other sites More sharing options...
RTFC Posted January 18, 2018 Share Posted January 18, 2018 (edited) AutoIt runs out of the box in several flavours of Linux, under Wine. Currently supported are: Ubuntu, Debian, Fedora, MacOS (supported by WineHQ), and SUSE, Slackware, and FreeBSD (supported by the distros). Wine supports AutoIt3 and Scite (the script editor that also drives the AutoIt interpreter and compiler). Edited January 18, 2018 by RTFC My Contributions and Wrappers Spoiler BitMaskSudokuSolver BuildPartitionTable CodeCrypter CodeScanner DigitalDisplay Eigen4AutoIt FAT Suite HighMem MetaCodeFileLibrary OSgrid Pool RdRand SecondDesktop SimulatedAnnealing Xbase I/O Link to comment Share on other sites More sharing options...
Earthshine Posted January 18, 2018 Share Posted January 18, 2018 I think he wants them to run as native Linux apps, otherwise, what would be the point? My resources are limited. You must ask the right questions Link to comment Share on other sites More sharing options...
RTFC Posted January 18, 2018 Share Posted January 18, 2018 That depends entirely on the application. More importantly, why rewrite from scratch when you can just run/recompile the original? My Contributions and Wrappers Spoiler BitMaskSudokuSolver BuildPartitionTable CodeCrypter CodeScanner DigitalDisplay Eigen4AutoIt FAT Suite HighMem MetaCodeFileLibrary OSgrid Pool RdRand SecondDesktop SimulatedAnnealing Xbase I/O Link to comment Share on other sites More sharing options...
antmar904 Posted January 18, 2018 Author Share Posted January 18, 2018 9 minutes ago, RTFC said: AutoIt runs out of the box in several flavours of Linux, under Wine. Currently supported are: Ubuntu, Debian, Fedora, MacOS (supported by WineHQ), and SUSE, Slackware, and FreeBSD (supported by the distros). Wine supports AutoIt3 and Scite (the script editor that also drives the AutoIt interpreter and compiler). Wine is not an option in this case, thank you for the note though. Link to comment Share on other sites More sharing options...
antmar904 Posted January 18, 2018 Author Share Posted January 18, 2018 13 minutes ago, Earthshine said: Python is SUPER. It's not hard to convert one to the other, but with Python, you have a choice of add in packages you can use for various things but in the end, the code is much different. I'll post a small sample from another thread where I posted a function that locates a running process. I need to create a Python script that will read a txt file of ip addresses and convert them into hostnames. That is my goal. Thanks again. Link to comment Share on other sites More sharing options...
Earthshine Posted January 18, 2018 Share Posted January 18, 2018 (edited) check out the reverse of what you want https://stackoverflow.com/questions/34573322/read-a-list-of-hostnames-and-resolve-to-ip-addresses then to you would just need to use socket.gethostbyaddr() instead Edited January 18, 2018 by Earthshine My resources are limited. You must ask the right questions Link to comment Share on other sites More sharing options...
antmar904 Posted January 18, 2018 Author Share Posted January 18, 2018 2 minutes ago, Earthshine said: check out the reverse of what you want https://stackoverflow.com/questions/34573322/read-a-list-of-hostnames-and-resolve-to-ip-addresses then to you would just need to use socket.gethostbyaddr() instead Thanks @Earthshine I actually just ran into the article!! Link to comment Share on other sites More sharing options...
Earthshine Posted January 18, 2018 Share Posted January 18, 2018 (edited) Just now, antmar904 said: Thanks @Earthshine I actually just ran into the article!! oops, you want the answers code import socket with open("test.txt", "r") as ins: for line in ins: print socket.gethostbyname(line.strip()) then use gethostbyaddr, no problem man. Carry on. Python rules. Edited January 18, 2018 by Earthshine My resources are limited. You must ask the right questions Link to comment Share on other sites More sharing options...
antmar904 Posted January 18, 2018 Author Share Posted January 18, 2018 1 hour ago, Earthshine said: oops, you want the answers code import socket with open("test.txt", "r") as ins: for line in ins: print socket.gethostbyname(line.strip()) then use gethostbyaddr, no problem man. Carry on. Python rules. This is not working, I keep getting "NULL": import socket pfile = open ('/root/Desktop/ip.txt') while True: IP = pfile.readline() try: host = socket.gethostbyaddr(ip.rstrip()) print(IP,host) except: print(IP,"NULL") pfile.close() Here is the output: Link to comment Share on other sites More sharing options...
Earthshine Posted January 18, 2018 Share Posted January 18, 2018 (edited) uh... I have to set up python. gimme a few, my dev vm should have it though. Edited January 18, 2018 by Earthshine My resources are limited. You must ask the right questions Link to comment Share on other sites More sharing options...
antmar904 Posted January 18, 2018 Author Share Posted January 18, 2018 5 minutes ago, Earthshine said: uh... I have to set up python. gimme a few, my dev vm should have it though. Ok so I changed it to this and is working but I would like to output to another txt file and clean up the output a bit: import socket for IP in open('/root/Desktop/IP.txt').readlines(): try: host = socket.gethostbyaddr(IP.rstrip()) print(IP,host) except Exception as e: print(IP,"NULL") Thanks again Link to comment Share on other sites More sharing options...
Earthshine Posted January 18, 2018 Share Posted January 18, 2018 (edited) great work. now search google for what you want to do with python. I assume you could just pipe it at the command line? as for cleaning up there is plenty of string functions to get you by in Python. Happy programming and check back if your script is not working for assistance. Edited January 18, 2018 by Earthshine My resources are limited. You must ask the right questions Link to comment Share on other sites More sharing options...
Earthshine Posted January 18, 2018 Share Posted January 18, 2018 (edited) I changed the code a bit to stop when no more addresses are found. import socket pfile = open ('c:\\test.txt') while True: ip = pfile.readline() try: host = socket.gethostbyaddr(ip.rstrip()) print(host) except: break pfile.close() produces Quote ('whitestar.xxxxxxx.local', [], ['192.168.1.93']) ('BUILD1', [], ['192.168.1.34']) [Finished in 0.2s] Notice host is a passed back as a Dictionary so cleanup will involve working with that, like a hash in Perl I named my dev vm WhiteStar because I love that old Sci-Fi series BABYLON 5 LOL Edited January 18, 2018 by Earthshine My resources are limited. You must ask the right questions Link to comment Share on other sites More sharing options...
antmar904 Posted January 18, 2018 Author Share Posted January 18, 2018 2 minutes ago, Earthshine said: I changed the code a bit to stop when no more addresses are found. import socket pfile = open ('c:\\test.txt') while True: ip = pfile.readline() try: host = socket.gethostbyaddr(ip.rstrip()) print(host) except: break pfile.close() produces Notice host is a passed back as a Dictionary so cleanup will involve working with that, like a hash in Perl thanks! I got the same results with the extra character "[]" and removed it from the output: import socket for IP in open('/root/Desktop/ip.txt').readlines(): try: host = socket.gethostbyaddr(IP.rstrip()) hostname = host[0] print(IP.rstrip(),hostname) except Exception as e: print(IP.rstrip(),"NULL") Output: ('1.1.1.1', 'hostname.domain') ('2.2.2.2', 'hostname.domain') Earthshine 1 Link to comment Share on other sites More sharing options...
Earthshine Posted January 18, 2018 Share Posted January 18, 2018 (edited) Verified, your code works great. when it hots one that it cannot lookup it prints NULL, verified. you are good to go man. now compare that with the autoit code. you can see, you can do A LOT MORE with a lot less typing with Python and C# and such. Edited January 18, 2018 by Earthshine My resources are limited. You must ask the right questions Link to comment Share on other sites More sharing options...
antmar904 Posted January 18, 2018 Author Share Posted January 18, 2018 2 minutes ago, Earthshine said: Verified, your code works great. when it hots one that it cannot lookup it prints NULL, verified. you are good to go man. thanks again for pointing me in the right direction. this is the first python script I've played with. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now