Im using raspberry pi and i want to control another windows machine by sending command using winexe. i can use the command directly from the terminal. However if i use python to send the command, the command seems invalid.
i can run this command at the terminal with no problem
winexe -U pc1%ppc1 //ipaddress 'netsh interface show interface'
i know its not practical to use os.system but the syntax works fine for me if use it with python
os.system('winexe -U pc1%ppc1 //ipaddress "netsh interface show interface"')
when i want to quote another syntax. with the terminal i run it and it works perfectly fine
winexe -U pc1%ppc1 //ipaddress 'netsh interface set interface "Local Area Connection admin=disable'
How can i use python to run the syntax for above line? i have already tried with
os.system('winexe -U pc1%ppc1 //ipaddress "netsh interface set interface "Local Area Connection" admin=disable"')
but the code cant run its just loading forever. its like i quote it wrongly. anyway to fix this?
You have not said exactly what error it gives you, however
i think the problem could be that you try to use 3 nested quotes
' " " " " '
but you should use a third type of quote (`) to make it works
' " ` ` " '
so
os.system('winexe -U pc1%ppc1 //ipaddress "netsh interface set interface `Local Area Connection` admin=disable"')
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.