خرید بک لینک

Vote count: 0

I imagine this question has been asked before, however I could not find a previous question regarding this.

So let's say I have a python script helloPython.py, which prints something. Now I want to call that script from within a bash script, which can be done like this. All good so far.
However, the right python path isn't necessarily always the first python executable as found in PATH, so I declare a global variable containing a default path and have a read in function to enable the user to give a custom path to a python executable.

To elaborate, this is my code:

#!/bin/bash
PYTHON="/usr/bin/python" #default address

function helloPython {
    return PYTHON helloPython.py;
}

function readin {
    ## Read in the options
    for i in "$@"
    do
    case $i in
        -p=*|--python=*)
        PYTHON="${i#*=}"
        shift
        ;;
        *)

        ;;
    esac
    done
}

readin
helloPython

This gives: "return: PYTHON: numeric argument required" Alternatively, return $(PYTHON helloPython.py); gives "PYTHON: command not found" and return $($(PYTHON) checkPythonVersion.py); gives "PYTHON: command not found n checkPythonVersion.py: command not found"

So now my question is: How can I use the global variable PYTHON in such a way that I can execute the python script from within bash?

asked 25 secs ago

برچسب: نویسنده: استخدام کار تاريخ: دوشنبه 28 فروردين 1396 ساعت: 21:43

صفحه بندی