[Tutor] Dual interface app

Mike Hansen mhansen at cso.atmel.com
Thu Aug 12 17:21:59 CEST 2004

I'm thinking of making an program that can be run from the command line 
or through a web page. The program requires a couple of arguments. At 
first I thought I could check the command line arguments, and if they 
didn't exist check the cgi form values. However, I started running into 
problems when I thought this out further. What if someone runs it from a 
command line and forgets to add the arguments? The program will check 
for command line arguments, then it will check the cgi form values and 
assume it's being called from the web interface. The responses would 
have to be either in text or html.
One solution I thought of was to get the command line interface working 
in one program. Then write another program for the web interface 
importing the command line program and using the common functions.

Does anyone have any other ideas? Is there a way to detect if a program 
is being called from the command line vs web without too much voodoo?


More information about the Tutor mailing list