To make a script to run remote commands in a client server network.
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) # Replace these with your actual credentials and command...
In case you have an old legacy system with Python 2 still in use and want to make a script to run certain commands in a client server network.
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, error = ssh_process.communicate() if...
Step 1: Open Settings in Windows 11
Step 2: Go to Apps
Step 3: Go to Advanced app settings
Step 4: Go to App execution aliases
Step 5: Disable the option for python.exe and python3.exe
Step 1: install Python
Step 2: add both the scripts folder and its parent folder to the path
Step 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