I am a beginner in these things, so please go light on me!
At the suggestion of a community member, I ask this question here, in addition to StackOverflow.
I have a device which I connect to my PC (Windows machine) via USB and after rooting SSH SSH-ing into it as an user, I can change the date and time using the following command:
date -s '2019-08-21 05:12:44'
I can obviously do that by hand, but I would like to learn how can I bring the Windows machine time into that command line.
Thank you very much!
Edit: It is a custom built hardware which runs Linux and it has 3 real-time clocks. I connect it to the PC via USB cable, but it has builtin Bluetooth and WiFi capabilities.
Second edit: I wanted to say that I SSH into the device as the "root" user.
Using Python with the Paramiko library I managed to bring the Windows machine time into the Linux one with the following code:
import datetime
import paramiko
import time
#create SSH client
client = paramiko.SSHClient()
#automatically add the host key
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
#connect to the Linux device
client.connect('address', username='username', password='password')
#delay subsequent commands by 10s to be sure the connection is established
time.sleep(10)
#execute command
stdin, stdout, stderr = client.exec_command(str(str("date -s '" + str(datetime.datetime.now()))[:-7] + "'")) #bring in the local Windows machine time
stdin.close()
print(stdout.read(),)
Strangely enough, if I don't use the following line of code, it doesn't work:
stdin.close()
Thank you very much for your help!