0

I have such a program to check methods of data from the command line:

me at me in ~/Desktop/Coding/codes $ cat check_methods.py #! /usr/bin/env python from sys import argv methods = dir(eval(argv[1])) methods = [i for i in methods if not i.startswith('_')] print(methods) me at me in ~/Desktop/Coding/codes $ python check_methods.py list ['append', 'clear', 'copy', 'count', 'extend', 'index', 'insert', 'pop', 'remove', 'reverse', 'sort'] me at me in ~/Desktop/Coding/codes $ python check_methods.py dict ['clear', 'copy', 'fromkeys', 'get', 'items', 'keys', 'pop', 'popitem', 'setdefault', 'update', 'values'] 

I'd like to run the program directly from bash, like:

$ check_methods.py list -bash: check_methods.py: command not found 

How to achieve it ?

    1 Answer 1

    4

    Specify the path to the script, since it isn't in $PATH.

    ./check_methods.py list 

    And never add . to $PATH.

    3
    • 1
      They could add $HOME/Desktop/Coding/codes to the end of $PATH if they wanted. Or move the script to $HOME/local/bin or some such location and add that to the end of $PATH.
      – Kusalananda
      CommentedMay 10, 2018 at 7:04
    • $ ./check_methods.py dict -bash: ./check_methods.py: Permission denied $ sudo ./check_methods.py dict sudo: ./check_methods.py: command not found Must it transmit to $PATH before it works?
      – Wizard
      CommentedMay 10, 2018 at 7:08
    • 2
      No, but you need to make it executable, just like every other executable in existence.CommentedMay 10, 2018 at 7:15

    You must log in to answer this question.

    Start asking to get answers

    Find the answer to your question by asking.

    Ask question

    Explore related questions

    See similar questions with these tags.