Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7497871
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T19:15:28+00:00 2026-05-29T19:15:28+00:00

I have the following contents in the file demo.py:- // executable bit set #!/usr/bin/python

  • 0

I have the following contents in the file

demo.py:- // executable bit set

#!/usr/bin/python
import os

i have used the command bash demo.py in the terminal and expecting that the
first line is interpreted by the bash and it handles the file to python interpreter.
But it calls the binary “/usr/bin/import”(figured using strace). The same is with sh demo.py.
However running ./demo.py works. man bash says

“If the program is a file beginning with #!, the remainder of the first
line specifies an interpreter for the program.”

which is not happening.

Using bash version

$ bash –version

GNU bash, version 4.2.8(1)-release (i686-pc-linux-gnu)
Copyright (C) 2011 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

in Ubuntu 11.04

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T19:15:35+00:00Added an answer on May 29, 2026 at 7:15 pm

    The bash documentation is correct: when you enter ./demo.py at the bash command prompt, bash uses the shebang line to figure out what executable will run the script.

    When you do bash demo.py then of course bash is going to try to run it as a bash script. Because you told it to. (Imagine if you had a bash script with an incorrect shebang line — how would you run it? By passing it directly to bash, in just this way.)

    If you want to start another bash shell which runs your Python script, then use bash -c ./demo.py to execute demo.py as a bash command rather than as a bash script. But you shouldn’t need to start another shell just to run a Python script.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following contents in my XML file: <items> <item id=1><content><![CDATA[<p>string</p>]]></content></item> </items> I
So I have an xml file with the following simplified xml file contents: <CollectionItems>
I have a text file with the following contents: 3,3,5,7,9,10,1 I can read the
I have the following use case, my file contents look like this a b
Have a Sql Script file name spCreation.sql with the following contents. CREATE PROCEDURE dbo.usp_select_customers
I currently have a batch file with the following contents to generate the Liquibase
I have a file say file.txt with following contents: Capsule arr[0] in state A
I have a file in visual studio with the following contents:{Name:Pete} If I read
I have the following code: <? $serverurl = $_SERVER[DOCUMENT_ROOT]; $file = $serverurl.'/demo/sample_php.php'; $newfile =
I have the following contents in a file called test2.txt . >>> def faulty():

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.