Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

kali linux run python script anywhere

# Make a python script:

cd /home/el/bin
touch stuff.py
chmod +x stuff.py

# Find out where your python is:

which python
/usr/bin/python

# Put this code in there:

#!/usr/bin/python
print "hi"

# Run in it the same directory:

python stuff.py

# Go up a directory and it's not available:

cd ..
stuff.py
-bash: stuff.py: command not found

# Not found! It's as we expect, add the file path of the python file to 
# the $PATH

vi ~/.bashrc

# Add the file:

export PATH=$PATH:/home/el/bin

# Save it out, re apply the .bashrc, and retry

source ~/.bashrc

# Try again:

cd /home/el
stuff.py

# Prints:

hi

# The trick is that the bash shell knows the language of the file via 
# the shebang.
Comment

PREVIOUS NEXT
Code Example
Python :: how to output varibles in python 
Python :: Filter dataarray 
Python :: lib.stride_tricks.sliding_window_view(x, window_shape, axis=None, *, subok=False, writeable=False) 
Python :: pythonmodules.txt 
Python :: regex library with def (apply , lambda) 
Python :: multiple channel creating command in discord.py 
Python :: calculate time between datetime pyspark 
Python :: sum of two diagonals in matrix 
Python :: dataframe conditional formatting max values 
Python :: `nlp.add_pipe` now takes the string name of the registered component factory 
Python :: install first person controller python 
Python :: asserts pytest for function called more than once 
Python :: dickyfuller test in python 
Python :: Another example: using a colorbar to show bar height 
Python :: supervisor gunicorn virtualenv flask 
Python :: python web app with redis github 
Python :: python ask for real values until negative value diplay highest and lowest 
Python :: voting classifier with different features 
Python :: pythongalaxy.com 
Python :: what is horse riding sport name 
Python :: python read stdin to string 
Python :: panda3d attach to bone 
Python :: fibonacci sequence python code 
Python :: python mypy cast 
Python :: python selenium for desktop application 
Python :: powershell open file with default program 
Python :: invalid literal for int() with base 10 python 
Python :: how to get data from multiple tables in django 
Python :: return Response converting to string drf 
Python :: Run flask on docker with postgres and guinicorn 
ADD CONTENT
Topic
Content
Source link
Name
2+1 =