[Resolved] How can i use FOG WOL in python3 script
-
Hello,
i would like to use FOG WOL to wake up computers with my ics file.
FOG don’t do that and i want script this if it’s possible.
If you have idea to do that with python3thxs
-
@Crok said in How can i use FOG WOL in python3 script:
wake up computers with my ics file.
What exactly do you mean by that?
-
i can use a ics file with “timetable”.
At each hour, i want wake up PC in term of ics file.
My file must be modified, is that reason i download my ics file at each hour and if my computer must wake up, i want use FOG WOL for this or a magic packet in my python3 script. -
i see you use a script perl to wol computers
https://wiki.fogproject.org/wiki/index.php?title=How_to_use_the_wakeonlan_perl_script_instead_of_etherwake.exe# Written by Marc Balmer, marc@msys.ch, http://www.msys.ch/ # This code is free software under the GPL import struct, socket def WakeOnLan(ethernet_address): # Construct a six-byte hardware address addr_byte = ethernet_address.split(':') hw_addr = struct.pack('BBBBBB', int(addr_byte[0], 16), int(addr_byte[1], 16), int(addr_byte[2], 16), int(addr_byte[3], 16), int(addr_byte[4], 16), int(addr_byte[5], 16)) # Build the Wake-On-LAN "Magic Packet"... msg = b'\xff' * 6 + hw_addr * 16 s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) s.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1) s.sendto(msg, ('1.2.3.255', 9)) s.close() # saisir l'adresse MAC de la machine WakeOnLan('00:11:22:33:44:55')
I try with this script.
-
@Crok I am still not exactly sure what you are trying to do. It sounds like you want to send WOL to clients on a regular basis, e.g. hourly?!
If that is what you want, then FOG should be able to do this for you. Select one host in the webUI -> Basic Tasks -> Advanced -> Wake-Up -> Schedule cron-style -> select “Hourly” from the list
Re-reading some of your other posts I get the impression that this is not what you want. So please tell us more about where this mysterious “ics file” is coming from. What is generating this and how? On what basis?
The PERL script you posted might work but there are ready to use Linux tools to send WOL packets as well. Look into packages called
etherwake
andwakeonlan
. That’s Debian/Ubuntu and I am sure you find those in CentOS/Fedora as well if you are using one of those. -
@Sebastian-Roth
I have an organizer that define when computers are used.
Monday -> my computer must be wake up at 10Am
Next monday -> at 8am
All wake up are differents for each computers and each days.
My organizer (calendar) is an .ics file can extract.
https://fr.wikipedia.org/wiki/ICalendar
i would like use this ics file to wake up my computers automatically.
my ics file must be modified, i do extract each hour.
Sorry my english is so bad.
i hope that is more clearly. -
@Crok Ok, now I got you. Unfortunately I won’t have enough time to come up with a solution to that. So you need to try it yourself. To get back to the initial request, a quick search on the web revealed many projects/libs/… that do wake on lan in python:
https://pypi.org/project/wakeonlan/
https://github.com/bentasker/Wake-On-Lan-Python
https://gist.github.com/rschuetzler/8854764So it’s just a matter of getting into coding and get it done. This has nothing much to do with what we can do for you as a FOG team.