Om een script te maken voor het uitvoeren van externe commando's in een client-servernetwerk.
import subprocess def ssh_exec_command(hostname, username, command): ssh_cmd = ['ssh', f'{username}@{hostname}', command] ssh_process = subprocess.Popen( ssh_cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True ) output, error = ssh_process.communicate() if error: print("Error:", error) else: print("Output:", output) # Vervang deze door uw...
In het geval u een oud legacysysteem heeft waarop nog Python 2 wordt gebruikt en u een script wilt maken om bepaalde commando's uit te voeren in een client-servernetwerk.
import subprocess def ssh_exec_command(hostname, username, private_key_path, command): ssh_cmd = ['ssh', '-i', private_key_path, '-o', 'StrictHostKeyChecking=no', f'{username}@{hostname}', command] ssh_process = subprocess.Popen( ssh_cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE ) output,...
Stap 1: Open Instellingen in Windows 11
Stap 2: Ga naar Apps
Stap 3: Ga naar Geavanceerde app-instellingen
Stap 4: Ga naar App-uitvoeringsaliassen
Stap 5: Schakel de optie voor python.exe en python3.exe uit
Stap 1: installeer Python
Stap 2: zet de scripts folder en de boven liggende folder allebij in het path
Stap 3: CMD> pip install pywin32
# File name: version_used.py
# This prints the version of Python being used by the Code Runner extension in VSCodium
# Set by going to: File -> Preferences -> Settings -> Search Settings -> code-runner.executorMap -> Edit in settings.json
# “python”: “/bin/python3.9 -u”,\
# To run this script press the little play button on the top right in the editor
import sys
print(sys.version)
$ sudo apt install software-properties-common
$ sudo add-apt-repository ppa:deadsnakes/ppa
$ sudo apt update
$ sudo apt install python3.9
$ python3.9 —version