CGi doesn’t work that way. CGI involves having the operating system execute a binary executable (machine code) which processes input and generates output. This happens in a CGI enironment, where the web server is a gateway in which special environment variables are used.
The script file is text data. It is not a binary executable. The script file needs to be loaded by ‘python’, which is a binary executable. The ‘python’ executable compiles the script into bytecode and “runs” the bytecode using a virtual machine.
The command ‘lynx hello.py’ does not do that. It simply tells lynx to open the file as text.
The command ‘python hello.py’ will try to execute the script, but since it would not be running in a CGI environment, the script will most likely fail or not work as expected.
To execute the script in a CGI environment, you need a web server. Then you need to access the script through the web server. And to do that, you need a URL.
Thus the command you want to use is: ‘lynx http://example.com/hello.py’
Scripts can be written to pretend they are in a CGI environment, so that you don’t have to use a web server. If you are not familiar with CGI environment, then you have a lot of reading to do.
Start with Dynamic Content with CGI
Perl / MySQL / HTML+CSS