LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
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
 
LinkBack Search this Thread
Old 07-07-2010, 03:26 PM   #61
bluegospel
Member
 
Registered: Jan 2010
Distribution: centOS
Posts: 404

Original Poster
Rep: Reputation: 53

I'm trying to execute my program, setting the environmental variable "CONTENT_LENGTH" to "7", & passing the string, "jazzman" to stdin, manually, in a shell as my test environment.

I think I've managed to set CONTENT_LENGTH to 7 using printenv & export, but I'm not sure how to run my program, passing "jazzman" to stdin via the shell, bypassing my html form (just to test).

Actually, I'm not sure whether this is what you mean Sergei, when you say "test environment."
 
Old 07-07-2010, 05:26 PM   #62
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 451Reputation: 451Reputation: 451Reputation: 451Reputation: 451
Quote:
Originally Posted by bluegospel View Post
... I'm not sure how to run my program, passing "jazzman" to stdin via the shell, bypassing my html form (just to test). ...
?????

This is still a UNIXish system.

Code:
echo "whatever you want to be printed to stdout" | program_expecting_that_something_from_stdin
.
Or

Code:
cat some_text_file_with_input_data | program_expecting_that_something_from_stdin
.

Last edited by Sergei Steshenko; 07-07-2010 at 05:27 PM.
 
Old 07-08-2010, 12:38 AM   #63
Wim Sturkenboom
Senior Member
 
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Slackware 10.1/10.2/12, Ubuntu 12.04, Crunchbang Statler
Posts: 3,786

Rep: Reputation: 282Reputation: 282Reputation: 282
Quote:
Originally Posted by bluegospel View Post
Okay, my code finally compiles, but when I post to the binary file from an html form saved to the same folder there's a popup that says, "You have chosen to open "schedule_payment" (the name of my binary) which is a: Binary File from: /home/barth/cppexperiments
Would you like to save this file?"
The message simply implies that the webserver does not execute it but passes it straight to the browser. I'm not familiar with this part of webservers, but should that file not be in a cgi directory on a webserver?
 
Old 07-08-2010, 03:48 AM   #64
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 451Reputation: 451Reputation: 451Reputation: 451Reputation: 451
Quote:
Originally Posted by Wim Sturkenboom View Post
... but should that file not be in a cgi directory on a webserver?
AFAIK, it should. The directory, I think, is called 'cgi-bin'.
 
Old 07-08-2010, 09:38 AM   #65
bluegospel
Member
 
Registered: Jan 2010
Distribution: centOS
Posts: 404

Original Poster
Rep: Reputation: 53
Quote:
should that file not be in a cgi directory on a webserver?
I'm aware that cgi-scripts are always executed from a special cgi-bin on a server, but I'm trying to execute this file as an ordinary program using output from an HTML form. I don't intend to use the final version of this particular program from the web. Is it possible to execute a regular binary file locally by use of input from a local HTML form?
 
Old 07-08-2010, 09:58 AM   #66
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 451Reputation: 451Reputation: 451Reputation: 451Reputation: 451
Quote:
Originally Posted by bluegospel View Post
... Is it possible to execute a regular binary file locally by use of input from a local HTML form?
Yes.
 
Old 07-08-2010, 10:25 AM   #67
bluegospel
Member
 
Registered: Jan 2010
Distribution: centOS
Posts: 404

Original Poster
Rep: Reputation: 53
Quote:
Quote:
Originally Posted by bluegospel:
... Is it possible to execute a regular binary file locally by use of input from a local HTML form?

Yes.
. . . With this in mind, how do I set up my files to act the way I want--to execute my binary rather than trying to open it? What are the implications of the following :

Quote:
The message simply implies that the [system] does not execute it but passes it straight to the browser.
Here's my form again:

Code:
<html><head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">

</head><body><form action="schedule_payment" method="POST">

<basefont size="3">

Payee: <input name="payee" type="text"><br>

Description: <input name="description" type="text"><br><br>

Frequency:<br>
<input name="frequency" value="weekly" type="radio"> Weekly <br>

<input name="frequency" value="bi-weekly" type="radio"> Bi-weekly <br>
<input name="frequency" value="semi-monthly" type="radio"> Semi-monthly<br>
<input name="frequency" value="monthly" type="radio"> Monthly<br>
<input name="frequency" value="quarterly" type="radio"> Quarterly<br>
<input name="frequency" value="semi-annually" type="radio"> Semi-annually<br>
<input name="frequency" value="annual" type="radio"> Annually<br><br>

Type Payment:<br>
<input name="flux" value="fixed" type="radio"> Fixed <br>
<input name="flux" value="variable" type="radio"> variable <br><br>

Amount of payment: (leave blank if "variable" is selected above) <input name="amount" type="text"><br>
<pre><font face="Times New Roman" size="3">Date of first scheduled payment: <input name="firstpayment" type="text">  (mm/dd/yyyy)</font><br></pre>

<input value="Submit" type="submit">



</form> </body></html>
And my binary:

Code:
#include <iostream>
#include <cstdlib>
#include <stdlib.h>
#include <cstdio>
#include <stdio.h>
#include <malloc.h>
#include <string.h>
#include <stddef.h>

using namespace std;

int main()
{
  char* billschedContentLength = getenv("CONTENT_LENGTH");
  char* billschedBuffer;
  int nContentLength = atoi(billschedContentLength);
  

  billschedBuffer = (char*) malloc(nContentLength+1);  // allocate a buffer
  memset(billschedBuffer, 0, nContentLength+1);  // zero it out

  fread(billschedBuffer,1,nContentLength,stdin);  // get data

   cout << "Content-type: text/html" << endl << endl
   << "<html>" << endl
   << "<body>" << endl
   << "<p>" << endl
   
   <<billschedBuffer<<""<<endl

   << endl
   << "" << endl
   << "" << endl
   << "" ;


  free(billschedBuffer);

  return 0;

}
Any help will be appreciated.

Last edited by bluegospel; 07-08-2010 at 10:32 AM.
 
Old 07-08-2010, 12:15 PM   #68
bluegospel
Member
 
Registered: Jan 2010
Distribution: centOS
Posts: 404

Original Poster
Rep: Reputation: 53
In other words, I want to output the information from the form to my executable, without the use of a server.

I can view html forms in my browser and use its links w/out connecting to a server. Can I also execute a binary program that's not kept on any server (in a cgi-bin), or does that always entail cgi?

Basically I want to write & use small applications using my browser as a user interface, without accessing a server. Is this possible?
 
Old 07-08-2010, 12:40 PM   #69
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 451Reputation: 451Reputation: 451Reputation: 451Reputation: 451
Quote:
Originally Posted by bluegospel View Post
...
Basically I want to write & use small applications using my browser as a user interface, without accessing a server. Is this possible?
The very basic idea of WEB browser is to implement secure browsing, which implies no application invoking on client side. The exceptions are Active-X and Java applets, but, AFAIK, they do not write to files.

I think you are becoming vague. And I still do not understand why what you are doing is now implemented in C++. C(++) implementation is necessary for very fast response times, like in stock trading systems.
 
Old 07-08-2010, 01:50 PM   #70
bluegospel
Member
 
Registered: Jan 2010
Distribution: centOS
Posts: 404

Original Poster
Rep: Reputation: 53
Thank you. That answers my question.

As to yours, I'm learning C++ because it appears to be used more widely than any other language, and it comes up a lot in discussions about programming; the same reason I'm learning linux.

You're right. I am being vague. Primarily because the material I'm ultimately attempting to learn is both very broad & dense, & also cryptic, including directly working with such protocols as ssl, et. al. (which at the moment are completely enigmatic to me).

Are you suggesting that I use something such as Perl? I like Perl, but the discussions usually come around again to Linux. The Linux discussions usually turn again to C.

By the way, what's AFAIK?
 
Old 07-08-2010, 02:02 PM   #71
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 451Reputation: 451Reputation: 451Reputation: 451Reputation: 451
Quote:
Originally Posted by bluegospel View Post
...
Are you suggesting that I use something such as Perl? I like Perl, but the discussions usually come around again to Linux. The Linux discussions usually turn again to C.

By the way, what's AFAIK?
AFAIK == "As Far As I Know".

However much I like Perl, the tools should be selected according to the task. If you need text parsing and data structures, Perl is very convenient and pretty fast.

The rule of thumb WRT WEB and C++ is that one needs C++ when response time should be milliseconds.

I didn't quite understand

Quote:
I like Perl, but the discussions usually come around again to Linux
.

Though any known to me Linux distro has Perl installed by default, Perl and Linux are orthogonal in mathematical terms. I.e., for example, there are two well known Perl "packages" for Windows - ActiveState Perl and Strawberry Perl. And, of course, Perl exists for any UNIXish system.
 
Old 07-08-2010, 02:28 PM   #72
bluegospel
Member
 
Registered: Jan 2010
Distribution: centOS
Posts: 404

Original Poster
Rep: Reputation: 53
I've always just been curious about C++.

What about very sensitive data, like personal financial information? Can SSL be implemented with just HTML & Perl without big out-of-pocket expenses to such as VeriSign? Can I work directly with different protocols?

-----

Quote:
I didn't quite understand


Quote:
I like Perl, but the discussions usually come around again to Linux
I just meant I'm studying linux because, in my limited use of Perl (on a Windows platform), the discussions quite often refer to linux.

By the way Sergei, thanks for staying with me for so long. I understand it requires perseverance to continue at this basic level for so long as someone very experienced in the subject. I don't take your time for granted.

Last edited by bluegospel; 07-08-2010 at 02:31 PM.
 
Old 07-08-2010, 03:06 PM   #73
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 451Reputation: 451Reputation: 451Reputation: 451Reputation: 451
Quote:
Originally Posted by bluegospel View Post
I've always just been curious about C++. ...
Then you've chosen a very strange starting point.

There are lot of tutorials around, so better start with/from basic things and forget about cgi-bin and WEB-specific things for a time being. You have a lot of things to learn without the WEB specifics.

By the way, that first program you've picked from that tutorial is not that C++-ish - it's rather "C" with artificially pulled into it C++ IO.

And you can learn C++ on Windows too, and you do not need MS VC for that - there is MinGW, there is CYGWIN. It's not that I'm recommending Windows, but if you feel more comfortable, then up to you.

As said, better start from basic "C" - without C++.
 
Old 07-08-2010, 03:31 PM   #74
bluegospel
Member
 
Registered: Jan 2010
Distribution: centOS
Posts: 404

Original Poster
Rep: Reputation: 53
I don't mean to be overbearing or contradict myself, but my interest in C/C++ is partly curiosity and partly practical, albeit, admittedly, my approach is purely unconventional.

As to the practical, perhaps I should move back towards Perl, but please answer my question addressing ssl and other protocols, because eventually I'm going to need them. Can I experiment first with TCP/IP, eventually moving on to things like SSL, using just HTML & Perl? Otherwise, I'll take your advice and explore C some, although I'm a little worried that some of what I learn will result in bad habits or obsolescence in C++ environments, not knowing what to keep and what to dismiss in C.
 
Old 07-08-2010, 03:57 PM   #75
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 451Reputation: 451Reputation: 451Reputation: 451Reputation: 451
Quote:
Originally Posted by bluegospel View Post
I don't mean to be overbearing or contradict myself, but my interest in C/C++ is partly curiosity and partly practical, albeit, admittedly, my approach is purely unconventional.

As to the practical, perhaps I should move back towards Perl, but please answer my question addressing ssl and other protocols, because eventually I'm going to need them. Can I experiment first with TCP/IP, eventually moving on to things like SSL, using just HTML & Perl? Otherwise, I'll take your advice and explore C some, although I'm a little worried that some of what I learn will result in bad habits or obsolescence in C++ environments, not knowing what to keep and what to dismiss in C.
http://search.cpan.org/search?query=SSL&mode=all
 
  


Reply

Tags
c++, executable, execute, form, program


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Errors, Errors, and more Errors (KDE 3.4.x GUI Errors) Dralnu Linux - Software 2 05-13-2006 08:30 AM
Qt errors devit Programming 1 02-09-2004 03:45 PM
Errors during filesystem check with one kernel while no errors with other kernel Potentials Linux - General 11 12-30-2003 04:24 AM
QMAIL errors errors.. YourForum Linux - Software 0 11-27-2003 12:30 PM
2 many errors wesley Linux - Newbie 1 08-02-2001 11:42 PM


All times are GMT -5. The time now is 01:01 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration