Search code examples
pythonpython-3.xcommandbackground-process

How to run a python script as a background process that takes different parameters from the command prompt?


I want to run a python program that runs in the background. It takes a folder directory and size as parameters and and compresses the files in the folder which are greater than the provided size. Also it will show description of the program that is in helpInfo() method if given the parameter

-h

. I have written the program normally here

Now how to run this program as a background process with path and size info given as parameters and will show help information if given parameter -h


Solution

  • from documentation of argparse

    import argparse
    parser = argparse.ArgumentParser()
    parser.add_argument("echo")
    args = parser.parse_args()
    

    Then using python3 prog.py --help