How to start up Python scripts on a Linux VPS

Degen

Elite Member
Joined
Apr 9, 2016
Messages
2,604
Reaction score
2,899
For anyone that is not familiar with coding in general..

Window users like their GUI
So we will be starting off with downloading a few programs

Winscp: https://winscp.net/eng/download.php
Putty : https://www.putty.org/

When you have them both installed open WinSCP
It will look like this
dh0y2W5

get the Linux VPS info from your hosting and insert that into the correct lines

IngAyam

Press login and you will be connected to the VPS ( you will see all the folder in the right side of the window (while the left side is your desktop)
tZLZTQV

Now you need to get your Python script onto your VPS.
You can simple search the file in the left part (desktop) and drag it to the right part (VPS).

Now that the file is copied over to your VPS you now need to do something out of your comfort zone !!!

We are going to open Putty from within WinSCP

Click on 'New session'
TF1fzFY
Right click the VPS and open Putty
6UReSvy

You will be asked to enter your VPS password
I recommend you to COPY your password and paste it by pressing your right mouse button ( the cursor will not move in the password line so there is no indication of you having typed in anything!!), press enter!
nWMIIaS

Now that we have connected to the VPS we need to install a few things before we can start using our scripts!

First time installs (copy paste and press enter)

Python 3

Check if you have python 3 installed
the command for that is
Code:
python3 --version
If it is not installed use
Code:
sudo apt-get install python3.8

TMUX

I personally use TMUX to get multiple scripts running on the same VPS
To install TMUX use
Code:
sudo apt-get install tmux
You will get a choice to continue (y/n) obviously choose y if you want to install it.

If you are using Reddit API (PRAW)

If you are using Reddit API related scripts like me you need to have PRAW installed
the code for that is
Code:
pip3 install praw
( if you get an error, try
Code:
pip install praw
)


Now that we have everything installed we can now run our scripts


Running your scripts


(we are going to run them in TMUX)

type tmux
Your screen will change into
B8ernVI

Press the following keys CTRL + b then SHIFT + 4 (
mf6792o
)
You can now rename the window (make it something short rememberable) , if you have named it press enter

The python file you have copied at the start of this tutorial is probably still in the main area of the server. (if it is in a folder type cd [foldername] )

We are going to invoke the script here with the following line

Python3 [yourscriptname].py

htJZvtW
The green cursor will move to the start on a new line, now we can leave this tmux window

Leave the TMUX by pressing CTRL +b and then d .
SY8K4hW

to see the TMUX windows you have active

see all active TMUX windows: tmux ls
My list of current tmux windows
6WsvqEI

to attach to a certain tmux window : tmux a -t [yourtmuxname]

i33WYk5

press enter . You will be back where you had started your script.

To stop your script : CTRL + C
 
Back
Top