Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I run a python script from a file? (UNIX)

Tags:

python

unix

Basically what I want to do is make a file called doPython and in this file I want to do the command:

python myFile.py data.txt

I've tried Googling and making a few scripts but I can't seem to get it to work. It says "No such file or directory when I try with

#!/usr/bin/env python
python myFile.py data.txt
like image 572
JLndl Avatar asked Mar 06 '26 06:03

JLndl


1 Answers

#!/usr/bin/env python says that your script is to be run with the Python interpreter. You just need to call sh or bash:

#!/bin/sh
python myFile.py data.txt
like image 162
Blender Avatar answered Mar 08 '26 19:03

Blender



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!