Hello,
How do I read an environment variable from my gpc Pascal program? This should enable me to accept data input via a form on the Web.
- Andy Ball
On Sun, 3 Apr 2005, Andy Ball wrote:
Hello,
How do I read an environment variable from my gpc Pascal program? This should enable me to accept data input via a form on the Web.
Try predefined function GetEnv in unit gpc.pas: function GetEnv (const EnvVar: String): TString; Ernst-Ludwig
Ernst-ludwig Bohnen wrote:
On Sun, 3 Apr 2005, Andy Ball wrote:
Hello,
How do I read an environment variable from my gpc Pascal program? This should enable me to accept data input via a form on the Web.
Try predefined function GetEnv in unit gpc.pas: function GetEnv (const EnvVar: String): TString; Ernst-Ludwig
I might be entirely wrong here. But I seem to recall you are working on CGI programming.
My guess is "Environment Variable" means different things when referring to shell programs such as bash or tcsh, or when referring to httpd programs such as Apache.
It might be worth checking out the ParamStr function.
Hello,
RE> I might be entirely wrong here. But I seem to recall > you are working on CGI programming.
That's right.
RE> My guess is "Environment Variable" means different > things when referring to shell programs such as bash > or tcsh, or when referring to httpd programs such as > Apache.
In case it does, I'll clarify. By 'environment variable' I mean it in same sense that bash, tcsh or sh would. For example $TERM might contain 'vt220'.
RE> It might be worth checking out the ParamStr function.
Thanks. Hopefully the Web servers will be back up soon and I will be able to look this one up.
- Andy Ball
On Mon, 4 Apr 2005, Andy Ball wrote:
RE> It might be worth checking out the ParamStr function.
Thanks. Hopefully the Web servers will be back up soon and I will be able to look this one up.
meanwhile:
ParamStr built-in ========
(Under construction.)
Synopsis
function ParamStr (ParmNumber: Integer): String;
Description
*Please note:* If you are using the Dos (DJGPP) or MS-Windows (mingw32) version of GPC and are getting unexpected results from `ParamStr', please see the section "Command-line Arguments Handling in DJGPP" of the DJGPP FAQ list.
Conforming to
`ParamStr' is a Borland Pascal extension.
Example
program ParamStrDemo;
var i: Integer;
begin WriteLn ('You have invoked this program with ', ParamCount, ' arguments.'); WriteLn ('These are:'); for i := 1 to ParamCount do WriteLn (ParamStr (i)) end.
See also
Hope this helps Russ
p.s. does anyone know what the dot-quad number is for "www.gnu-pascal.de"? perhaps the server is up but only the name is deleted from the dns database.
p.s. does anyone know what the dot-quad number is for "www.gnu-pascal.de"? perhaps the server is up but only the name is deleted from the dns database.
Nslookup gives me:
Non-authoritative answer: www.gnu-pascal.de canonical name = tartaglia.dida.physik.uni-essen.de. Name: tartaglia.dida.physik.uni-essen.de Address: 132.252.79.79
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
Running telnet on port 80 (www) of that IP address allows me to establish a connection. However, entering a command (get /) causes the connection to stall. So apparently the door is open, but nobody's home?
I get a similar result from bad http commands.
On Apr 4, 2005, at 4:52 PM, Waldek Hebisch wrote:
p.s. does anyone know what the dot-quad number is for "www.gnu-pascal.de"? perhaps the server is up but only the name is deleted from the dns database.
Nslookup gives me:
Non-authoritative answer: www.gnu-pascal.de canonical name = tartaglia.dida.physik.uni-essen.de. Name: tartaglia.dida.physik.uni-essen.de Address: 132.252.79.79
-- Waldek Hebisch hebisch@math.uni.wroc.pl
- ----------------------------------------------------------- Frank D. Engel, Jr. fde101@fjrhome.net
$ ln -s /usr/share/kjvbible /usr/manual $ true | cat /usr/manual | grep "John 3:16" John 3:16 For God so loved the world, that he gave his only begotten Son, that whosoever believeth in him should not perish, but have everlasting life. $
___________________________________________________________ $0 Web Hosting with up to 200MB web space, 1000 MB Transfer 10 Personalized POP and Web E-mail Accounts, and much more. Signup at www.doteasy.com
Rick Engebretson wrote:
Ernst-ludwig Bohnen wrote:
On Sun, 3 Apr 2005, Andy Ball wrote:
How do I read an environment variable from my gpc Pascal program? This should enable me to accept data input via a form on the Web.
Try predefined function GetEnv in unit gpc.pas: function GetEnv (const EnvVar: String): TString; Ernst-Ludwig
I might be entirely wrong here. But I seem to recall you are working on CGI programming.
My guess is "Environment Variable" means different things when referring to shell programs such as bash or tcsh, or when referring to httpd programs such as Apache.
Not really -- CGI programs get some of their information via environment variables (that's why it's possible to write limited CGI programs in bash using $FOO). Other data (e.g. from POST requests) are sent via stadard input however.
BTW, I also have a working CGI unit ready in http://fjf.gnu.de/misc/cgiprogs.tar.bz2 (which supports both GET and POST requests, and internally uses environment variables and standard input as necessary, of course).
Frank
Frank Heckenbach wrote:
Rick Engebretson wrote:
Ernst-ludwig Bohnen wrote:
On Sun, 3 Apr 2005, Andy Ball wrote:
How do I read an environment variable from my gpc Pascal program? This should enable me to accept data input via a form on the Web.
Try predefined function GetEnv in unit gpc.pas: function GetEnv (const EnvVar: String): TString; Ernst-Ludwig
I might be entirely wrong here. But I seem to recall you are working on CGI programming.
My guess is "Environment Variable" means different things when referring to shell programs such as bash or tcsh, or when referring to httpd programs such as Apache.
Not really -- CGI programs get some of their information via environment variables (that's why it's possible to write limited CGI programs in bash using $FOO). Other data (e.g. from POST requests) are sent via stadard input however.
BTW, I also have a working CGI unit ready in http://fjf.gnu.de/misc/cgiprogs.tar.bz2 (which supports both GET and POST requests, and internally uses environment variables and standard input as necessary, of course).
Frank
Yes really -- I recalled the young man had posted before on CGI forms. Forms environment variables are different than shell variables. Since then he was more specific.
Rick Engebretson wrote:
My guess is "Environment Variable" means different things when referring to shell programs such as bash or tcsh, or when referring to httpd programs such as Apache.
Not really -- CGI programs get some of their information via environment variables (that's why it's possible to write limited CGI programs in bash using $FOO). Other data (e.g. from POST requests) are sent via stadard input however.
BTW, I also have a working CGI unit ready in http://fjf.gnu.de/misc/cgiprogs.tar.bz2 (which supports both GET and POST requests, and internally uses environment variables and standard input as necessary, of course).
Yes really -- I recalled the young man had posted before on CGI forms. Forms environment variables are different than shell variables. Since then he was more specific.
Actually they are the same. E.g., a CGI program gets passed a variable called GATEWAY_INTERFACE to identify the CGI interface, a variable REQUEST_METHOD to identify the method (GET, POST, PUT), a variable QUERY_STRING (for GET) with the form contents etc.
As I said it's possible to use these variables in shell scripts, and AFAIR Apache distributions contain simple such demo scripts. For more complex tasks and especially POST and PUT, shell scripts are probably not the optimal solution, and even for simple tasks it's probably somewhat harder to get shell scripts secure, but there's no fundamental difference to the nature of the variables. (Which is no surprise since environment variables are the main means, besides "command-line" arguments (which really aren't command-line specific), to pass information to a new process by the OS.)
Frank
Hello,
ASB> How do I read an environment variable from my gpc > Pascal program?
ElB> Try predefined function GetEnv in unit gpc.pas: > function GetEnv (const EnvVar: String): TString;
How do I tell gpc that my program uses the gpc unit? Also, what is a TString?
- Andy Ball
On 4 Apr 2005 at 12:58, Andy Ball wrote:
Hello,
ASB> How do I read an environment variable from my gpc > Pascal program?
ElB> Try predefined function GetEnv in unit gpc.pas: > function GetEnv (const EnvVar: String): TString;
How do I tell gpc that my program uses the gpc unit?
program foo; uses gpc; begin Writeln ('Your path = ', GetEnv ('PATH')); end.
Also, what is a TString?
It is defined in gpc.pas (as "String (2048)", IIRC).
Best regards, The Chief --------- Prof. Abimbola Olowofoyeku (The African Chief) Web: http://www.greatchief.plus.com/
ASB> How do I tell gpc that my program uses the gpc unit?
AO> uses gpc;
Logical enough! (I like Pascal :-)
I'm not sure whether I need to feed gpc some kind of library prefix, but when I try compiling my program I get...
test4.pas:2: module/unit interface `Gpc' could not be imported
- Andy Ball
On 4 Apr 2005 at 14:07, Andy Ball wrote:
ASB> How do I tell gpc that my program uses the gpc unit?
AO> uses gpc;
Logical enough! (I like Pascal :-)
I'm not sure whether I need to feed gpc some kind of library prefix, but when I try compiling my program I get...
test4.pas:2: module/unit interface `Gpc' could not be imported
gpc --automake foo.pas { to "make" } or gpc --autobuild foo.pas { to rebuild all }
Best regards, The Chief --------- Prof. Abimbola Olowofoyeku (The African Chief) Web: http://www.greatchief.plus.com/