I am trying to execute the following command from my python script, using subprocess :
date -s "25 DEC 2021 15:30:00"
This is how i am executing the command :
command_date = ("/usr/bin/date -s \"{0}\"".format(config_date))
print("command date : ",command_date)
proc = subprocess.Popen(command_date.split(), stdout = subprocess.PIPE, encoding = "utf8")
result_date = proc.stdout.read()
print("\nNew system date : ", result_date)
But i am getting the following error :
/usr/bin/date: extra operand '2021'
After some tests directly by the terminal, the error apprear if i am using the command without the quotes around the date string. But my variable command_date is well constructed (see print : /usr/bin/date -s "25 DEC 2021 15:30:00"
)
Do you know why my quotes are ignored and how to fix it ?