Ask Question Forum:
Model Library:2025-02-08:A.I. model is online auto reply
C
O
M
P
U
T
E
R
2
8
Show
#
ASK
RECENT
←
- Underline
- Bold
- Italic
- Indent
- Step
- Bullet
- Quote
- Cut
- Copy
- Paste
- Table
- Spelling
- Find & Replace
- Undo
- Redo
- Link
- Attach
- Clear
- Code
Below area will not be traslated by Google,you can input code or other languages
Hint:If find spelling error, You need to correct it,1 by 1 or ignore it (code area won't be checked).
X-position of the mouse cursor
Y-position of the mouse cursor
Y-position of the mouse cursor
Testcursor
caretPos
Attachment:===
Asked by duncanb7
at 2024-12-07 22:49:45
Point:500 Replies:6 POST_ID:828544USER_ID:11059
Topic:
Scripting Languages;Perl Programming Language;PHP Scripting Language
Today I study perl and cgi usage and concept and just want to ask some question after goolge serach some infomation at following link
http://www.htmlcodetutorial.com/forms/index_famsupp_6.html
http://www.whizkidtech.redprince.net/cgi-bin/tutorial
Question-1) I know php , and I am able to run any php program in my Linux server by php command
and I also able to run my php at my IE broswer on XP just typing http://www.mysite.com/example.php
I just want to clarify. Because my hosting company already installed CGI program on my server so that my users and I are able to run perl, php, c language on IE or any browsers through CGI program on my server THe CGI program is handling users(client-side) on browser's request through post and get request and execute
any script program in server such as php, perl, c..etc.
Question-2 CGI program is language program, what type of language is C or others? Could I take
a look of CGI program look like in editor ?
Question-3 Why I don't have cgi-bin directory at my linux server if I am able to run php script on my IE browser? Or it doesn't matter to have cgi-bin directory or not because it is not related to whether I have installed
CGI program or not, and cgi-bin is just directory to store related program or script ?
Quesiton-4, On my Cpanel I got one icon that is cgi center . Is the cgi center means there is a lot of
script program similar to php prgram that can run on any browser for users throught CGI program on server ?
Finally question), people say Perl is out-dated lanauge for web traffice application because today now
they are using php lanauge to replace perl. Is it right ? So I don't need to do starting study on Perl and
so I just need to concentrate on php that is already good enough ? but why I Awstat web stat software is
still using Perl ?
Please advise
Duncan
http://www.htmlcodetutorial.com/forms/index_famsupp_6.html
http://www.whizkidtech.redprince.net/cgi-bin/tutorial
Question-1) I know php , and I am able to run any php program in my Linux server by php command
and I also able to run my php at my IE broswer on XP just typing http://www.mysite.com/example.php
I just want to clarify. Because my hosting company already installed CGI program on my server so that my users and I are able to run perl, php, c language on IE or any browsers through CGI program on my server THe CGI program is handling users(client-side) on browser's request through post and get request and execute
any script program in server such as php, perl, c..etc.
Question-2 CGI program is language program, what type of language is C or others? Could I take
a look of CGI program look like in editor ?
Question-3 Why I don't have cgi-bin directory at my linux server if I am able to run php script on my IE browser? Or it doesn't matter to have cgi-bin directory or not because it is not related to whether I have installed
CGI program or not, and cgi-bin is just directory to store related program or script ?
Quesiton-4, On my Cpanel I got one icon that is cgi center . Is the cgi center means there is a lot of
script program similar to php prgram that can run on any browser for users throught CGI program on server ?
Finally question), people say Perl is out-dated lanauge for web traffice application because today now
they are using php lanauge to replace perl. Is it right ? So I don't need to do starting study on Perl and
so I just need to concentrate on php that is already good enough ? but why I Awstat web stat software is
still using Perl ?
Please advise
Duncan
Author: duncanb7 replied at 2024-12-24 00:27:06
Better understanding
Duncan
Duncan
Assisted Solution
Expert: Tintin replied at 2024-12-08 11:54:06
125 points GOOD
Question-1) While it is possible to invoke a PHP script via CGI, most PHP code is embedded in HTML and run by the embedded PHP interpreter in the web server.
Question-2) CGI is not a programming language. It is an interface. It's a little like an API.
Question-3) /cgi-bin was the traditional location for CGI programs, but it depends on your webserver configuration. It is also common to use a file association. For example, any file ending in .pl is treated as a CGI program.
Quesiton-4) Yes, although some of them would be quite outdated.
Finally question) For web apps, Perl has definitely fallen out of favour with PHP being the most common. However, there are still a lot of Perl apps out there, particularly for non-web purposes.
awstats was written many years ago (I think it was before PHP was invented), hence Perl was the best language for it.
Question-2) CGI is not a programming language. It is an interface. It's a little like an API.
Question-3) /cgi-bin was the traditional location for CGI programs, but it depends on your webserver configuration. It is also common to use a file association. For example, any file ending in .pl is treated as a CGI program.
Quesiton-4) Yes, although some of them would be quite outdated.
Finally question) For web apps, Perl has definitely fallen out of favour with PHP being the most common. However, there are still a lot of Perl apps out there, particularly for non-web purposes.
awstats was written many years ago (I think it was before PHP was invented), hence Perl was the best language for it.
Assisted Solution
Expert: Ferrosti replied at 2024-12-08 05:02:27
125 points GOOD
You´ve got some error in this.
In case your web server has PHP, perl, python or whatever language compiled in, you won´t need to access it via CGI. Apache call this mod_perl, mod_php or whatever.
To understand the last two sentences you need to know that running apache with mod_php will execute your php program within the boundaries and limits of this apache process. User permissions as well as memory usage limits, etc. from apache will limit this php process, too. This can be useful to not allow flooding your webserver.
Running your program in a CGI environment will make apache hand over POST and GET vars to the php program and execute it outside of its own process, wait for it to complete and then return its values (html code) to the client. It is quite clear that last case is slower, since php is an interpreted language and your program is compiled every time before execution, while mod_php may precompile and cache the program.
In case your web server has PHP, perl, python or whatever language compiled in, you won´t need to access it via CGI. Apache call this mod_perl, mod_php or whatever.
To understand the last two sentences you need to know that running apache with mod_php will execute your php program within the boundaries and limits of this apache process. User permissions as well as memory usage limits, etc. from apache will limit this php process, too. This can be useful to not allow flooding your webserver.
Running your program in a CGI environment will make apache hand over POST and GET vars to the php program and execute it outside of its own process, wait for it to complete and then return its values (html code) to the client. It is quite clear that last case is slower, since php is an interpreted language and your program is compiled every time before execution, while mod_php may precompile and cache the program.
Assisted Solution
Expert: venloft replied at 2024-12-08 03:22:15
125 points GOOD
Yes, you could say is a way to allow programs to output to web browsers, how ever remember is not limited to PHP o PERL.
For your question, its how PHP is configured on the Http server.
You can request www.mysite.com/example.php because the PHP interpeter has been compiled inside the Http server
also take a look at this http://docs.joomla.org/Should_PHP_run_as_a_CGI_script_or_as_an_Apache_module%3F
In the above link youll have an interesting reading about, in summary of keynotes:
As a HTTP module PHP is runing in the same process that was created.
Runing as CGI you create a process each time you run a php script
For your question, its how PHP is configured on the Http server.
You can request www.mysite.com/example.php because the PHP interpeter has been compiled inside the Http server
also take a look at this http://docs.joomla.org/Should_PHP_run_as_a_CGI_script_or_as_an_Apache_module%3F
In the above link youll have an interesting reading about, in summary of keynotes:
There are two ways to configure Apache to use PHP:
Configure Apache to load the PHP interpreter as an Apache module
Configure Apache to run the PHP interpreter as a CGI binary
Configure Apache to load the PHP interpreter as an Apache module
Configure Apache to run the PHP interpreter as a CGI binary
As a HTTP module PHP is runing in the same process that was created.
Runing as CGI you create a process each time you run a php script
Author: duncanb7 replied at 2024-12-08 02:52:01
Now it is better after looking the wiki doc for CGI
Please correct me if it is mistake on what my understand or say as follows
CGI is a method defined by RC3875 to interpret web browser URL to run web server program such
as perl or php and stdout program output data back to wbe browser.
The following printnev.pl is CGI program or script to run perl program and output all
environment varaible. "pl" extentsion of printenv.pl is stand for perl
printenv.pl
===========================
#!/usr/local/bin/perl
##
## printenv—demo CGI program which just prints its environment
##
#
print "Content-type: text/plain";
foreach $var (sort(keys(%ENV))) {
$val = $ENV{$var};
$val =~ s||\n|g;
$val =~ s|"|\"|g;
print "${var}="${val}"";
}
So last question:
Why I can run my php program on my IE browser when I type for example, www.mysite.com/example.php? Is it because my server already installed CGI program or script
for php program to execute my php program ?
Please correct me if it is mistake on what my understand or say as follows
CGI is a method defined by RC3875 to interpret web browser URL to run web server program such
as perl or php and stdout program output data back to wbe browser.
The following printnev.pl is CGI program or script to run perl program and output all
environment varaible. "pl" extentsion of printenv.pl is stand for perl
printenv.pl
===========================
#!/usr/local/bin/perl
##
## printenv—demo CGI program which just prints its environment
##
#
print "Content-type: text/plain";
foreach $var (sort(keys(%ENV))) {
$val = $ENV{$var};
$val =~ s||\n|g;
$val =~ s|"|\"|g;
print "${var}="${val}"";
}
So last question:
Why I can run my php program on my IE browser when I type for example, www.mysite.com/example.php? Is it because my server already installed CGI program or script
for php program to execute my php program ?
Accepted Solution
Expert: venloft replied at 2024-12-08 01:11:39
125 points GOOD
Duncan,
First i think is important to understant what is CGI , it stands for Common Gateway Interface, http://en.wikipedia.org/wiki/Common_Gateway_Interface.
In short definition could be defined as way how external programs could interact with HTTP requests.
Trying to answer you same order
Q1) You are also able to run any CGI script if configured on server by command line or browser
ex. $ ./myscript.cgi, by browser http:/site.com/cgi/myscript.cgi
Scripts could recive or send data, you should study and review about benefits and disadvantages about tunning a script as cgi.
Q2) CGI is not language program, how could it look in an editor?, well that dependes on the individual programming language your using in the script. and which languages are configured to be allowed to run as CGI at server.
These CGI programs can be a PERL Script, Shell Script, C or C++ program, even PHP, etc.
You could tell which one si been used and syntaxis expected by reading first line that calls the proper interpreter or compiler.
ex.
#!/usr/bin/php
#!/usr/bin/perl
gcc -o Cfile.cgi
Q3) it depends on your http server configuration, it could be configured to run in a specific folder, or whole site, its all about how CGI is configured
Q4) Correct, depend on script you could configure it for your needs and install them according to your server instructions to be able to use them
Final question) Well in my personal opinion this is more about personal preferences in programming languages. i think its always good to learn languages and specialize in some or just in one, its also about needs, beneficts and disadvantages.
And following your line i could say that Phyton is going to replace PHP, ill state this diferent, maybe not the proper way but just for example. PHP is easier than Perl thats why most people use it, or just ask yourself, why arent you coding and making server side scripts in C language? for me is powerfull.
Hope this was helpfull to you what is CGI
regards
First i think is important to understant what is CGI , it stands for Common Gateway Interface, http://en.wikipedia.org/wiki/Common_Gateway_Interface.
In short definition could be defined as way how external programs could interact with HTTP requests.
Trying to answer you same order
Q1) You are also able to run any CGI script if configured on server by command line or browser
ex. $ ./myscript.cgi, by browser http:/site.com/cgi/myscript.cgi
Scripts could recive or send data, you should study and review about benefits and disadvantages about tunning a script as cgi.
Q2) CGI is not language program, how could it look in an editor?, well that dependes on the individual programming language your using in the script. and which languages are configured to be allowed to run as CGI at server.
These CGI programs can be a PERL Script, Shell Script, C or C++ program, even PHP, etc.
You could tell which one si been used and syntaxis expected by reading first line that calls the proper interpreter or compiler.
ex.
#!/usr/bin/php
#!/usr/bin/perl
gcc -o Cfile.cgi
Q3) it depends on your http server configuration, it could be configured to run in a specific folder, or whole site, its all about how CGI is configured
Q4) Correct, depend on script you could configure it for your needs and install them according to your server instructions to be able to use them
Final question) Well in my personal opinion this is more about personal preferences in programming languages. i think its always good to learn languages and specialize in some or just in one, its also about needs, beneficts and disadvantages.
And following your line i could say that Phyton is going to replace PHP, ill state this diferent, maybe not the proper way but just for example. PHP is easier than Perl thats why most people use it, or just ask yourself, why arent you coding and making server side scripts in C language? for me is powerfull.
Hope this was helpfull to you what is CGI
regards