I’m an experienced professional programmer, BUT I’ve done all my work on video game consoles in C and C++, nothing on PCs and nothing relating to networking. My question is, if I write a simple C console application (doing IO via printf and scanf), is there any vaguely easy way to put it up on a web page somewhere such that people from all over can run it through their web browsers?
thanks
If you want the console application to run on the server, then there isn’t any easy way of doing it if you’re not familiar with writing web applications. You’ll have to get into CGI, Perl(or a similar scripting language), .NET or Java, Enterprise Edition.
Are you talking about CGI programs, using a browser form as input and printing output to a web page? If so, this is not too hard, using just basic console style I/O. Or do you mean something else?
For CGI stuff, you can use a variety of languages to write the server side of things – I have a couple that I use (written quite a while back), written in C++. The basic gist is that you can use a form in html to receive input – if you submit with the POST method, it will come into the CGI program on standard input. You should be able to parse with cin (or scanf, for C programs). You have to know the basic format, and how to interpret special character codes, but it’s basically text processing. Then, you can write data OUT with standard output – writing the actual html code from the program, and have that output show up as a new web page (dynamically generated by the program).
If that’s the kind of thing you’re talking about – I can send you sample source code (one of the C++ ones I did) if you like.
The biggest difference between “console” applications and web-based applications is that you don’t have a real-time connection between the user and the server.
All interaction is based on an http request from the user and an http response from the server. Each request passes some information to the server and the response loads a page. You can’t do things like intercepting individual keystrokes and changing the display accordingly, but everything must be processed in batch mode, and every request/response cycle requires a round trip from the user to the server.
UNLESS you are using a scripting language, such as javascript or you write a java program which downloads and runs on the user’s machine. In either of those cases, the actual processing is done on the client side, and there is no interaction with the server until another request/response cycle is initiated.
You can write a web application that interfaces with a console application using tools like Expect. But it’s a lot of work to re-impliment the console interface in something useful for a web app and to pass all the data back and forth.
Seems surprising that someone hasn’t written a tool to basically make this easy, as there’s infinite quantities of printf/scanf tty-based code floating around out there.
Oh well, thanks anyhow…
I remember seeing some telnet applications that did something similar to that… would love to know how to do that, especially on a windows machine, if it’s possible. I remember experimenting with the ‘telnet server’ that’s included with windows server, but it doesn’t seem to have the ability to host custom command-line apps, just to provide a sort of DOS prompt into the server machine. At least, that’s what I remember, and I might not have seen the right option.
That kind of thing might do exactly what I need.