0
I'm looking for advice on the automated execution of a Python script by the Windows Task Scheduler.
The task is very simple: sending TCP commands over a wireless network at fixed times every day to turn on or turn off devices (video projectors).
Current setup: Windows Task Scheduler executes a Python script.
Current situation:
- The script runs successfully when executed manually
- The script runs successfully when the task that orders its execution in Task Scheduler is run manually (i.e. the "run" button for this task is manually clicked)
- The script does not run successfully when the task that orders its execution is run automatically by the Task Scheduler: only the first device is turned off.
- The projector ON script does seem to run properly
Point 2. tells me that it is not an admin permissions issue, that the network is setup properly, that the IP addresses are right, etc. - but I'm running out of ideas.
I've tried using Wireshark to track the TCP traffic on one of the malfunctioning devices but haven't found anything helpful yet. Same with the Windows Event Viewer. I'm running Windows 10.
The little 'turn off' script is pasted below. The 'turn on' script is essentially the same thing with a different message.
import socket
IP_1 = '192.168.0.41'
IP_2 = '192.168.0.42'
IP_3 = '192.168.0.43'
TCP_PORT = 33336
#BUFFER_SIZE = 1024
MESSAGE = 'POWER=OFF\r'
s1 = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s1.connect((IP_1, TCP_PORT))
s1.send(MESSAGE.encode())
s1.close()
s2 = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s2.connect((IP_2, TCP_PORT))
s2.send(MESSAGE.encode())
s2.close()
s3 = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s3.connect((IP_3, TCP_PORT))
s3.send(MESSAGE.encode())
s3.close()
Thank you for your help
Simply for troubleshooting purposes, does breaking the script up into 3 pieces change the behavior? – sippybear – 2020-02-24T23:12:10.110
That's a good idea. I'll create 3 tasks with a separate script each. – Léonard Roussel – 2020-02-25T15:08:13.437