The task is to programmatically obtain the name used to invoke the program. (For example determine whether the user ran "python hello.py", or "python hellocaller.py", a program importing the code from "hello.py".)

Sometimes a multiline shebang is necessary in order to provide the script name to a language's internal ARGV.

See also Command-line arguments

Examples from GitHub.

       identification division.
       program-id. sample.
 
       data division.
       working-storage section.
       01 progname pic x(16).
 
       procedure division.
       sample-main.
 
       display 0 upon argument-number
       accept progname from argument-value
       display "argument-value zero :" progname ":"
 
       display "function module-id  :" function module-id ":"
 
       goback.
       end program sample.