LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-10-2007, 05:15 AM   #1
expeliarmus
LQ Newbie
 
Registered: Jul 2007
Posts: 17

Rep: Reputation: 0
piping a web browser to a C program running in the shell


Hi,
I have a C program which requires 2 inputs,load average and time.I want to create a simple html page which accepts these two inputs in a form,and pipes these values to the C program,running in the shell,so as to make the input part GUI-enabled.
how can I accomplish this?
thanks
expelliarmus
 
Old 10-10-2007, 06:37 AM   #2
Wim Sturkenboom
Senior Member
 
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Ubuntu 12.04, Antix19.3
Posts: 3,794

Rep: Reputation: 282Reputation: 282Reputation: 282
I doubt that the piping can be done but I might be wrong. Some alternatives:
  1. add your own basic webserver to your C application
  2. add a native GUI to your C application
  3. add a very basic server to your C application and use another application to send the input; the latter can be written in a number of scripting languages that have Tk support (I use Tcl/Tk, but I'm quite sure the python and perl also have Tk support)
  4. use expect
I don't have experience with expect, but it would probably be what I would use for this (based on the info that you have supplied).
 
Old 10-10-2007, 06:38 AM   #3
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 65
Why would you want to use a pipe to get these values? There are C API calls for both of these - it can all be done from within your program.
 
Old 10-10-2007, 09:34 AM   #4
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
Why can't you simply use CGI? In fact, the underlying mechanism for CGIs using the POST method is exactly as you describe. Your CGI would have to re-issue some sort of HTML page, in order to make the process re-iterate, but simply printing a static page to stdout is pretty simple to do in C.
Building a simple web server into your application is also a quite do-able. It can be accomplished in a few tens of lines, or there are open source mini-http servers out there for embedding.
--- rod.

Last edited by theNbomr; 10-10-2007 at 09:37 AM. Reason: Added content.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Running a shell script from a web page anirbande Linux - Newbie 1 12-01-2006 01:36 PM
Problem running C++ program in Linux Shell Alkibiades Programming 17 10-28-2006 06:51 AM
Running shell script within a C or C++ program Quantum0726 Programming 2 06-15-2005 09:14 PM
running a program from shell script Suinatsa Programming 10 04-14-2005 11:25 AM
How to determine whether a PROCESS is running, by a SHELL program? yuzuohong Linux - General 4 01-21-2003 08:41 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:24 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration