Python Forum
Is possible to run the python command to call python script on linux?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Is possible to run the python command to call python script on linux?
#4
Save the following in your bash script folder as, for example, helloWorld.sh

Quote:# this is a bash script
echo "This is bash speaking, I am now starting helloWorld.py"
# put the path to your Python programme here
myPython/helloWorld.py

Now run the helloWorld.sh in bash as below, and the Python programme helloWorld.py will run.

Below is what you see in bash when you run helloWorld.sh:

Quote:pedro@pedro-HP:~$ helloWorld.sh
This is bash speaking, I am now starting helloWorld.py
This is Python speaking: Hello World
What is your name?
Peter
It is good to meet you,Peter
pedro@pedro-HP:~$

Like I said, helloWorld.sh and helloWorld.py must both be executable.

Don't forget the shebang at the top of your Python programme: #! /usr/bin/python3
cuten222 likes this post
Reply


Messages In This Thread
RE: Is possible to run the python command to call python script on linux? - by Pedroski55 - Jan-24-2024, 07:13 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  run part of a script with a different version of Python jdog 3 622 May-27-2024, 01:57 AM
Last Post: Alice12
Music Python Script Repeating Number When Saving Facebook Photos ThuanyPK 2 219 May-13-2024, 10:59 PM
Last Post: ebn852_pan
  Trying to generating multiple json files using python script dzgn989 4 325 May-10-2024, 03:09 PM
Last Post: deanhystad
  Problems passing arguments containing spaces to bash script and then on to python kaustin 6 607 Apr-03-2024, 08:26 PM
Last Post: deanhystad
  ChromeDriver breaking Python script genericusername12414 1 415 Mar-14-2024, 09:39 AM
Last Post: snippsat
  using PowerShell from Python script for mounting shares tester_V 8 697 Mar-12-2024, 06:26 PM
Last Post: tester_V
  No Internet connection when running a Python script basil_555 8 855 Mar-11-2024, 11:02 AM
Last Post: snippsat
Question Running Python script through Task Scheduler? Winfried 8 838 Mar-10-2024, 07:24 PM
Last Post: Winfried
  python script is hanging while calling a procedure in database prasanthi417 4 670 Jan-17-2024, 02:33 PM
Last Post: deanhystad
  How to check if Skype call is connected or disconnected in Python? boral 1 477 Dec-28-2023, 08:31 AM
Last Post: buran

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020