Skip to content

Commit 23eae7a

Browse files
committed
comments
1 parent 8aedaf1 commit 23eae7a

8 files changed

+376
-8
lines changed

sites/en/pages/set-up-cgi-with-apache.txt

Lines changed: 226 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
=status show
55
=author szabgab
66
=archive 1
7-
=comments_disqus_enable 1
7+
=comments_disqus_enable 0
88

99
=abstract start
1010

@@ -134,4 +134,229 @@ followed by 2(!) newlines.
134134
Check out all the articles related to <a href="https://perlmaven.com/cgi">CGI and Perl</a> and
135135
<a href="/hello-world-using-cgi-in-ruby">CGI and Ruby</a>.
136136

137+
<h2>Comments</h2>
138+
139+
A comment that was deleted before I decided to move them over.
140+
---
141+
142+
Well Said. I have been fighting this for 20 years. I set up an Apache Server, it runs for years, and when I go to do it again, everything is all moved around and it takes hours and hours to simply get a hello world program to run under apache. It is never clear on how to do it, they leave no instructions, For petes sake why doesn't the release at least have the file http.conf still there with the whole instruction set on how to get the functionality of http.conf working under the new paradigm??? It boggles the mind.
143+
144+
---
145+
146+
Thumbs up. Moving files around for no real gain makes the software difficult to use. I too spent hours trying to get things straight.
147+
148+
For other users, here's some advice that worked for me:
149+
150+
1: Enable the CGI subsystem with a2enmod cgid
151+
152+
2: Uncomment the CGI handler in mods-enabled/mime.conf, or include this directive in your specific vHost section
153+
154+
AddHandler cgi-script .cgi
155+
156+
3: Include Options ExecCGI in the vHost or topmost directory where you want these programs to be available
157+
158+
---
159+
160+
In fact, very most times I had any issue I lost patience with myself, I was able to get someone to take the the time and lead me step by step. The truth, however, is that you are suposed to spend some time reading and learning stuff yourself as people generally expect some basic level of knowledge.
161+
162+
And you know, I suspect you had neen doing some small stupid mistake, just as I sometimes do. But if you need an advice, you need to ask politely rather than throw feces.
163+
164+
<hr>
165+
166+
Oh thank you thank you thank you. 3 HOURS of searching before I found this article that finally talks about the CGI module and the soft link to fix this in mods-enabled. Why is this so well hidden on the internet is a mystery.
167+
168+
<hr>
169+
170+
After getting it to work with hello world, I tried to run one of my past cgi-perl scripts from an HTML page in my recent home apache2 server. The cgi-perl script runs fine as a webserver elsewhere - developed during my doctoral days. It's a long code: a certain bioinformatic application.
171+
172+
The HTML page calls the cgi-perl script using method 'GET' as follows:
173+
174+
<code>
175+
<form action="http://127.0.0.1/cgi-bin/newsdnamelt.cgi" method="GET">
176+
<center><input value="Run" type="submit"></center>
177+
</form>
178+
</code>
179+
180+
I am getting this error both with the HTML as well as with curl on command prompt:
181+
182+
Internal Server Error
183+
184+
The server encountered an internal error or misconfiguration and was unable to complete your request.
185+
186+
Please contact the server administrator at webmaster@localhost to inform them of the time this error occurred, and the actions you performed just before this error.
187+
188+
More information about this error may be available in the server error log.
189+
Apache/2.4.29 (Ubuntu) Server at 127.0.0.1 Port 80
190+
191+
Any hint would be deeply appriciated.
192+
193+
-----------------------------------------------------------------------------------------------------
194+
195+
- Thanks in anticipation and Warm Regards,
196+
197+
---
198+
199+
PS: Interestingly .sh scripts placed at /usr/lib/cgi-bin/ works just fine from HTML submit button - like the hw.sh.
200+
But none of the cgi-perl scripts do.
201+
202+
These scripts start in the following way and all of them have worked just fine from similar HTML submission pages in the past.
203+
So, I wonder what's wrong! Any advice would be of great help!
204+
205+
-------------------------------------------------------------------------------------------
206+
207+
#!/usr/bin/perl
208+
209+
use CGI qw(:standard);
210+
print "Content-type:text/html\n\n";
211+
212+
#============Input Environment variables======
213+
$inptype;$filename;$inpseq;$x;$y;$Temp;$Na;$K;$NH4;$Mg;$tag;$tparam,$ustartbp;
214+
#=============================================
215+
216+
$qstr = $ENV{QUERY_STRING};
217+
218+
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~env input from html~~~~~~~~~~~~~~~~~~~~
219+
$qstr="choice=dirseq&filename=&dnaseq=GCGCGCGCGCGCGatgtcgtacgcatgcgatcagtcagcgacaCGCGC&tag=&tparam=&startbp=&window=20&overlap=0&Temp=37&Na=0.165&K=0&NH4=&Mg=0.01";
220+
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
221+
222+
print $qstr,"\n";
223+
224+
@qdata = split(/&/,$qstr);
225+
#open (OUT,">ch.out");
226+
227+
---
228+
229+
230+
Are the scripts executable, can you get the errors from the log file of the server?
231+
232+
<hr>
233+
234+
Excellent discourse. Great sincerity in helping the community. Long live Linux and opensource coding!!
235+
236+
<hr>
237+
238+
thanks
239+
240+
<hr>
241+
242+
Hey! It works. :)
243+
244+
I'm now a "veteran" PHP dev. Because of that, I've not attempted traditional CGI scripting before but now I'm trying to add REBOL to my web dev toolbox and this is now necessary for me to do that. Funny thing... Your bash script example works but my REBOL script is returning a 500 Error for having a "malformed header" even though there are no typos and 2 newlines preceding the content. Off to find out why! Thanks for getting me going this far!
245+
246+
---
247+
248+
I think this usually happens if the code does not print the Content-Type properly.
249+
250+
<hr>
251+
252+
Thanks a lot sir!!
253+
254+
<hr>
255+
256+
Hi,
257+
258+
Instead of manually creating the symlink with
259+
260+
$ cd /etc/apache2/mods-enabled
261+
$ sudo ln -s ../mods-available/cgi.load
262+
263+
you should use the provided tool a2enmod. Ubuntu also provide a2disconf a2dismod a2dissite a2enconf and a2ensite for enabling and disabling modules, sites and configuration blocks
264+
265+
Thanks for all your work.
266+
267+
---
268+
269+
your post hi-lights exactly what is wrong with the linux community. You seem to think that " Ubuntu also provide a2disconf a2dismod a2dissite a2enconf and a2ensite for [this that and the other thing, that you don't provide any instructions for.]" is somehow better than just cutting and pasting the two lines:
270+
271+
$ cd /etc/apache2/mods-enabled
272+
$ sudo ln -s ../mods-available/cgi.load
273+
274+
this is exactly the problem with the linux community: If it ain't broke don't fix it.
275+
276+
ALL instructions should be cut and paste lines form the command line. The FIRST set of instructions on setting up Apache is getting the welome screen to come up (that actually works pretty well,) and the second thing should be how to set up cgi-bin. For who knows what reason apache instructions instead go into multiple virtual hosting environments with do-decagon multi-plexing, cross-over premium drivers... whatever thing that is so complex I wouldn't have a chance to follow. Meanwhile I'm stuck getting hello_world.c which I can easily compile with gcc: ($ gcc -o hello_world.exe hellow_world.c) to run through the browser. Its absolutely ridiculous. This should be a no-brainer and up and running in less than 30 seconds.
277+
278+
<hr>
279+
280+
thanks for the post. it helped me alot.
281+
282+
<hr>
283+
284+
Ah, is it this easy? Why have I been thinking it is somewhat bloody difficult? :o)
285+
286+
For the record, I had the cgid.load already present in my 2018-09-26 Raspbian Buster AND if you are getting that 500 server error, make sure the bash script is not indented (as was mine upon pasting it to nano).
287+
288+
Indeed, not it works from me from my other machines too, which sugests I will be able to drive my RasPi car from a web interface.
289+
290+
<hr>
291+
292+
Hello sir i am trying to configure apache files to run a cgi script
293+
on Apache2 server from last 5 days. please help. hope for your better reply..
294+
295+
when i ran my python(test.cgi) file on localhost server (localhost/test.cgi) it prints the code
296+
297+
<hr>
298+
299+
Many thanks!!!
300+
301+
<hr>
302+
303+
Thank you so much!!
304+
305+
<hr>
306+
307+
Thanks Gabor,
308+
It really help us . Earlier we were using centos and recently we migrated to Ubuntu and our health check was failing for one service which is exposed using cgi.
309+
310+
<hr>
311+
312+
curl http://127.0.0.1/cgi-bin/hw.sh seems to be throwing an error for me :(
313+
Where does your localhost point to ?
314+
315+
---
316+
What is the error?
317+
318+
aswin@aswin-desktop:~$ curl http://127.0.0.1/cgi-bin/hw.sh
319+
320+
<code>
321+
<html><head>
322+
<title>500 Internal Server Error</title>
323+
</head><body>
324+
<h1>Internal Server Error</h1>
325+
326+
The server encountered an internal error or
327+
misconfiguration and was unable to complete
328+
your request.
329+
330+
331+
Please contact the server administrator at
332+
webmaster@localhost to inform them of the time this error occurred,
333+
and the actions you performed just before this error.
334+
335+
336+
More information about this error may be available
337+
in the server error log.
338+
339+
340+
<hr>
341+
<address>Apache/2.4.18 (Ubuntu) Server at 127.0.0.1 Port 80</address>
342+
</body></html>
343+
344+
</code>
345+
346+
and what do you see in the error log of the server?
347+
348+
---
349+
350+
I actually reinstalled lubuntu and tried it again and it works now, this was mostly due to some modifications i did to some of my files.
351+
This article was really helpful :)
352+
Thanks!
353+
354+
<h2>
355+
356+
Thanks a lot for this article! :)
357+
358+
<h2>
359+
360+
The missing symlink saved the day! I had the correct apache conf file for site but the cgi was not enabled.
361+
137362

sites/en/pages/show-ads-to-visitors-based-on-referrer.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
=books javascript
77
=author szabgab
88
=archive 1
9-
=comments_disqus_enable 1
9+
=comments_disqus_enable 0
1010

1111
=abstract start
1212

@@ -35,4 +35,10 @@ same line as another element. There are a few additional values it can take, but
3535
In our code example we have two <hl>div</hl> elements. One of them is shown to 'internal visitors', the others to everyone else.
3636
Of course, you could use similar conditions to show specific message to people coming from Google or from any other site.
3737

38+
<h2>Comments</h2>
3839

40+
not working
41+
42+
---
43+
44+
my bad, works but it must be exactly the same url. Meaning that if you are on www.code-maven.com, this code won't work. It must be changed to code-maven.com (without www prefix).

sites/en/pages/simple-logging-in-python.txt

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
=books python
66
=author szabgab
77
=archive 1
8-
=comments_disqus_enable 1
8+
=comments_disqus_enable 0
99

1010
=abstract start
1111

@@ -107,4 +107,22 @@ The output will then change to:
107107
2018-06-12-08-51-30 CRITICAL MainProcess root critical
108108
</code>
109109

110+
<h2>Comments</h2>
111+
112+
```
113+
logging.basicConfig(level = logging.INFO, filename = "my.log")
114+
```
115+
116+
This statement won't create the log file automatically for you.
117+
118+
<hr>
119+
120+
121+
Have you tried https://simplelogging.readthedocs.io/en/latest/readme.html ?
122+
You don't have to remember the boilerplate anylonger.
123+
124+
<hr>
125+
126+
Log to file doesnt work with this code
127+
110128

sites/en/pages/stack-trace-in-javascript.txt

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
=indexes console, trace, arguments, callee, caller
44
=status show
55
=author szabgab
6-
=comments_disqus_enable 1
6+
=comments_disqus_enable 0
77

88
=abstract start
99

@@ -136,3 +136,14 @@ For even further details check out the
136136
<a href="https://developer.chrome.com/devtools/docs/console-api">console API of Chrome</a>
137137
and the
138138
<a href="https://developer.mozilla.org/en/docs/Web/API/console">console API of FireFox</a>.
139+
140+
141+
<h2>Comments</h2>
142+
143+
As far as I understand, "Stack trace using caller object" part doesn't work in modern browsers, after `arguments.callee.caller` deprecation, right?
144+
145+
<hr>
146+
147+
Thanks. It works well in Flash too!
148+
149+

sites/en/pages/system-information-about-a-file-or-directory-in-nodejs.txt

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
=books nodejs
66
=author szabgab
77
=archive 1
8-
=comments_disqus_enable 1
8+
=comments_disqus_enable 0
99

1010
=abstract start
1111

@@ -194,4 +194,21 @@ That's how our output resembles (in the usage of <hl>rwx-</hl> characters) to th
194194
Besides the read-write-execute flags, we can also extract the file-type from the the <hl>mode</hl>
195195
value, but for those we have already seen a set of more readable convenience methods.
196196

197+
<h2>Comments</h2>
198+
199+
I read the article several times, but I could not associate the same in my need, I need inside a folder to get the name of the last created file
200+
201+
<hr>
202+
203+
It is much easier to use stat-mode in order to get the user/group/others permissions https://www.npmjs.com/package/stat-mode
204+
205+
<hr>
206+
207+
Can anyone Answer me?
208+
I have List of files in the folder. i need to read the file from the folder while if i met criteria , i have to come out from the function and update the document.Ultimately i dont need to read all the files when condition met. using Node.js?
209+
210+
<hr>
211+
212+
Group and Owner permissions check looks wrong. Group execute should be stats["mode"] & 8, write should be stats["mode"] & 16 and so forth.
213+
197214

sites/en/pages/tmux.txt

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
=status show
55
=author szabgab
66
=archive 1
7-
=comments_disqus_enable 1
7+
=comments_disqus_enable 0
88

99
=abstract start
1010

@@ -104,4 +104,16 @@ Then you can attach yourself to any of the existing session:
104104

105105
See the article about <a href="http://www.rushiagr.com/blog/2016/06/16/everything-you-need-to-know-about-tmux-copy-pasting-ubuntu/">select-copy-paste in tmux</a>.
106106

107+
<h2>Comments</h2>
107108

109+
One of my favorite features of tmux that you did not mention is the `copy-mode` that makes you interact with the terminal history as if you were in an editor. You can search backwards, select and copy, and then paste into the same window/pane or in a different window. Much faster than using a mouse.
110+
111+
---
112+
113+
How do you do that?
114+
115+
---
116+
117+
See e.g.: http://www.rushiagr.com/blog/2016/06/16/everything-you-need-to-know-about-tmux-copy-pasting-ubuntu/
118+
119+
But basically you just enter it by «Hotkey»[ and you can then traverse the buffer in readonly mode, search it, mark it, and copy it into the tmux copy buffer. You can then paste from the tmux copy buffer (e.g. in another pane or window) with through «Hotkey»] .

0 commit comments

Comments
 (0)