I have a Proxmox Server and I tried to write a Python script to exec some command on them. I also have a vscode server that run on the Proxmox Server and in the vscode server the program work fine but when I'm trying the same code (copy paste) in the vscode that installed on my PC I get this error "'command' is not recognized as an internal or external command, operable program or batch file."
I connect to the Proxmox with netmiko and run the commands.
this code is the same on the vscode server and on my PC:
from netmiko import ConnectHandler
import re
import subprocess
linux = {
'device_type': 'linux',
'ip': '1.1.1.1',
'username': 'my_username',
'password': 'my_pass',
'port': 1111,
'verbose': True
}
connection = ConnectHandler(**linux)
output = connection.send_command('sudo pct list | tail -n +2')
pattern = "\d{3}"
getConID = re.findall(pattern , output)
print (getConID)
connection.disconnect()
for container in getConID:
execCommand = subprocess.getstatusoutput('sudo pct status ' + container)
print (execCommand[1])