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 8823807
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T06:27:03+00:00 2026-06-14T06:27:03+00:00

I have the following shell script to query the python version. It gives me

  • 0

I have the following shell script to query the python version. It gives me an error stating "Integer expression expected" on the if-statement.

#!/bin/bash


PYTHON_VERSION=`python -c 'import sys; print("%i" % (sys.hexversion<0x03000000))'`

echo $PYTHON_VERSION

if [ $PYTHON_VERSION -eq 0 ]
then
    echo "fine!"
fi

‘echo $PYTHON_VERSION’ prints out ‘0’, so why dosn’t the if-statement work?

EDIT: I am using Windows and Cygwin

  • 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-06-14T06:27:05+00:00Added an answer on June 14, 2026 at 6:27 am

    Good question. For me it’s working fine. You always should quote evaluated variables ("$X" instead of $X); maybe that fixes your error.

    But I propose to use the result of the python script instead of its output:

    #!/bin/bash
    if python -c 'import sys; sys.exit(1 if sys.hexversion<0x03000000 else 0)'
    then
        echo "Fine!"
    fi
    

    If you like to stay in the shell completely, you also can use the --version option:

    case "$(python --version 2>&1)" in
        *" 3."*)
            echo "Fine!"
            ;;
        *)
            echo "Wrong Python version!"
            ;;
    esac
    

    Maybe that’s more readable.

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

Sidebar

Related Questions

I have a shell script file (run.sh) that contains the following: #!/bin/bash %JAVA_HOME%/bin/java -jar
I have the following shell script. For some reason the java program's standard error
i have the following shell script- #!/bin/bash echo enter the full path of script;
In Applescript, I have the following: do shell script /Applications/Vidalia.app/Contents/MacOS/Vidalia do shell script /Applications/Firefox_3.6/Firefox.app/Contents/MacOS/firefox-bin
I have a shell script that includes the following command: /usr/local/bin/ssh -q -i /.ssh/id_rsa
I have the following shell script : #!/bin/sh output=`./process_test.sh status_pid | grep NOT STARTED:
I have the following to execute shell commands using Node: function puts( error, stdout,
I have the following shell script with finds all the files and then should
I have the following shell script and want to change the filename db_backup.sql to
gcc (GCC) 4.7.2 GNU bash, version 4.2.37 Hello, I have the following bash script

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.