Tux

...making Linux just a little more fun!

Talkback:166/ziemann.html

[ In reference to "Internet Radio Router" in LG#166 ]

Mulyadi Santosa [mulyadi.santosa at gmail.com]


Wed, 2 Sep 2009 22:27:37 +0700

This article reminds me to the day I made my first crude webmail using perl CGI. Not too good, but also not so bad considering the fact "It Just Works" and I made it using Perl while most of my friends would prefer using PHP to do such thing :)

Bash scripting for CGI....ouch that's just great! and old sk00lz too! :) Thanks Mr Ziemann for sharing your works....

-- 
regards,


Top    Back


Ben Okopnik [ben at linuxgazette.net]


Wed, 2 Sep 2009 11:54:21 -0500

On Wed, Sep 02, 2009 at 10:27:37PM +0700, Mulyadi Santosa wrote:

> This article reminds me to the day I made my first crude webmail using
> perl CGI. Not too good, but also not so bad considering the fact "It
> Just Works" and I made it using Perl while most of my friends would
> prefer using PHP to do such thing :)
> 
> Bash scripting for CGI....ouch that's just great! and old sk00lz too!
> :) Thanks Mr Ziemann for sharing your works....

I introduce my shell scripting students to CGI pretty regularly. It's a way for them to write a graphical app that runs on almost *every single OS* (via browser, obviously) by using very simple tools - an incredible "force multiplier". It also gets people out of thinking that shell scripting is a trivial hack, or doesn't have much power.

-- 
* Ben Okopnik * Editor-in-Chief, Linux Gazette * https://LinuxGazette.NET *


Top    Back


Mulyadi Santosa [mulyadi.santosa at gmail.com]


Wed, 2 Sep 2009 23:21:19 +0700

On Wed, Sep 2, 2009 at 11:54 PM, Ben Okopnik<ben@linuxgazette.net> wrote:

> On Wed, Sep 02, 2009 at 10:27:37PM +0700, Mulyadi Santosa wrote:
>> This article reminds me to the day I made my first crude webmail using
>> perl CGI. Not too good, but also not so bad considering the fact "It
>> Just Works" and I made it using Perl while most of my friends would
>> prefer using PHP to do such thing :)
>>
>> Bash scripting for CGI....ouch that's just great! and old sk00lz too!
>> :) Thanks Mr Ziemann for sharing your works....
>
> I introduce my shell scripting students to CGI pretty regularly. It's a
> way for them to write a graphical app that runs on almost *every single
> OS* (via browser, obviously) by using very simple tools - an incredible
> "force multiplier". It also gets people out of thinking that shell
> scripting is a trivial hack, or doesn't have much power.

Can't agree more than that! I think that also fits with versatility of most Linux/Unix tools I can say that bash is "one of the oldest swiss army knife".

bash does very well (since it's the nature of it) as a shell and scripting language, but with imagination it can also serve as other things too. let's see if somebody in TAG runs bash as web server in one of his/her machines :)

-- 
regards,


Top    Back


Ben Okopnik [ben at linuxgazette.net]


Wed, 2 Sep 2009 12:31:20 -0500

On Wed, Sep 02, 2009 at 11:21:19PM +0700, Mulyadi Santosa wrote:

> 
> bash does very well (since it's the nature of it) as a shell and
> scripting language, but with imagination it can also serve as other
> things too. let's see if somebody in TAG runs bash as web server in
> one of his/her machines :)

One of the other things I used to demonstrate to my students. :) I don't have it anymore - that was years ago - but a quick look around the Net suffices:

https://prd4.wynn.com:8080/

-- 
* Ben Okopnik * Editor-in-Chief, Linux Gazette * https://LinuxGazette.NET *


Top    Back


Mulyadi Santosa [mulyadi.santosa at gmail.com]


Wed, 2 Sep 2009 23:36:52 +0700

On Thu, Sep 3, 2009 at 12:31 AM, Ben Okopnik<ben@linuxgazette.net> wrote:

> On Wed, Sep 02, 2009 at 11:21:19PM +0700, Mulyadi Santosa wrote:
>>
>> bash does very well (since it's the nature of it) as a shell and
>> scripting language, but with imagination it can also serve as other
>> things too. let's see if somebody in TAG runs bash as web server in
>> one of his/her machines :)
>
> One of the other things I used to demonstrate to my students. :) I
> don't have it anymore - that was years ago - but a quick look around the
> Net suffices:
>
> https://prd4.wynn.com:8080/

Oh, what a nice example! Thanks for showing me that URL

-- 
regards,


Top    Back


Jim Jackson [jj at franjam.org.uk]


Wed, 2 Sep 2009 22:55:41 +0100 (BST)

On Wed, 2 Sep 2009, Mulyadi Santosa wrote:

> On Wed, Sep 2, 2009 at 11:54 PM, Ben Okopnik<ben@linuxgazette.net> wrote:
>> On Wed, Sep 02, 2009 at 10:27:37PM +0700, Mulyadi Santosa wrote:
>>> This article reminds me to the day I made my first crude webmail using
>>> perl CGI. Not too good, but also not so bad considering the fact "It
>>> Just Works" and I made it using Perl while most of my friends would
>>> prefer using PHP to do such thing :)
>>>
>>> Bash scripting for CGI....ouch that's just great! and old sk00lz too!
>>> :) Thanks Mr Ziemann for sharing your works....
>>
>> I introduce my shell scripting students to CGI pretty regularly. It's a
>> way for them to write a graphical app that runs on almost *every single
>> OS* (via browser, obviously) by using very simple tools - an incredible
>> "force multiplier". It also gets people out of thinking that shell
>> scripting is a trivial hack, or doesn't have much power.
>
> Can't agree more than that! I think that also fits with versatility of
> most Linux/Unix tools I can say that bash is "one of the oldest swiss
> army knife".
>
> bash does very well (since it's the nature of it) as a shell and
> scripting language, but with imagination it can also serve as other
> things too. let's see if somebody in TAG runs bash as web server in
> one of his/her machines :)

The web server at www.franjam.org.uk (80.177.18.41) is bash shell script run out of inetd, which I cra^Hufted myself. It doesn't do much, mainly does HTTP redirects to where some pages are. The http "Server:" name is "MickeyMouse0.1" :-)

See what Netcraft reports

https://uptime.netcraft.com/whats?host=www.franjam.org.uk

There's a static page at

https://www.franjam.org.uk/hello.test

and

https://www.franjam.org.uk/jj/...

gets redirected to

https://www.comp.leeds.co.uk/jj/...

There's are other private stuff on there too. I wrote it to try and learn a bit about HTTP. It's slow! But does ok for this job.

If anyone has any comments/advice on the HTTP it spits out, feel free to educate me.

I could make the (edited) sh script available if anyone is interested.

Jim


Top    Back


Rick Moen [rick at linuxmafia.com]


Wed, 2 Sep 2009 15:50:52 -0700

Quoting Jim Jackson (jj@franjam.org.uk):

> The web server at www.franjam.org.uk (80.177.18.41) is bash shell script  
> run out of inetd, which I cra^Hufted myself.

In case it's not obvious, the inetd superserver is extremely useful for these sorts of tricks, because it can open network sockets, which is the difficult part. (That's why "Web servers" in shell script, awk, or sed tend to lean on inetd -- though GNU awk has extensions that let you do without it.)

Not that I'm trying to pour cold water on neat shell scripting tricks, which I always admire.

(See also: https://www.debian-administration.org/article/A_web_server_in_a_shell_script)

-- 
Rick Moen              "The Internet sees your competence and wisdom as damage, 
rick@linuxmafia.com    and will route around it."  -- Anil Dash
                       https://twitter.com/anildash/status/2897466042


Top    Back


Jim Jackson [jj at franjam.org.uk]


Fri, 4 Sep 2009 10:56:12 +0100 (BST)

On Wed, 2 Sep 2009, Rick Moen wrote:

> Quoting Jim Jackson (jj@franjam.org.uk):
>
>> The web server at www.franjam.org.uk (80.177.18.41) is bash shell script
>> run out of inetd, which I cra^Hufted myself.
>
> In case it's not obvious, the inetd superserver is extremely useful for
> these sorts of tricks, because it can open network sockets, which is
> the difficult part.

Too true. I've used inetd and perl/Tcl/shell scripts for prototyping network services for ages. Many never left the prototype stage :-). Factor in the use of the tcpd access control program and you very get simple added security.

Thanks for the ref. below.

Jim

> (That's why "Web servers" in shell script, awk,
> or sed tend to lean on inetd -- though GNU awk has extensions that
> let you do without it.)
>
> Not that I'm trying to pour cold water on neat shell scripting tricks,
> which I always admire.
>
> (See also:
> https://www.debian-administration.org/article/A_web_server_in_a_shell_script)


Top    Back


Ben Okopnik [ben at linuxgazette.net]


Wed, 2 Sep 2009 18:16:04 -0500

On Wed, Sep 02, 2009 at 10:55:41PM +0100, Jim Jackson wrote:

>
> The web server at www.franjam.org.uk (80.177.18.41) is bash shell script  
> run out of inetd, which I cra^Hufted myself. It doesn't do much, mainly  
> does HTTP redirects to where some pages are. The http "Server:" name is  
> "MickeyMouse0.1" :-)

Shweet. :)

> There's are other private stuff on there too. I wrote it to try and learn 
> a bit about HTTP. It's slow! But does ok for this job.
>
> If anyone has any comments/advice on the HTTP it spits out, feel free to  
> educate me.

Well, let's see:

ben@Jotunheim:~$ nc www.franjam.org.uk 80
GET /index.html HTTP/1.1
 
HTTP/1.0 404 Not Found.
Server: MickyMouse0.1
Date: Wed, 02 Sep 2009 22:02:03 +0000
Connection: close Content-Type: text/html; charset=ASCII <html><head> <title>Not Found</title> <h2>43.sub-75-202-207.myvzw.com (75.202.207.43) requested <b><em>/index.html</em></b></h2> <h2>Page Not Found.</h2> </body></html>

I'm not 100% sure, but I don't believe that 'charset=ASCII' is a valid charset string (although 'charset="us-ascii"' is.) You should also send a DTD spec, i.e.

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
...

and so on.

-- 
* Ben Okopnik * Editor-in-Chief, Linux Gazette * https://LinuxGazette.NET *


Top    Back


Jim Jackson [jj at franjam.org.uk]


Fri, 4 Sep 2009 10:57:41 +0100 (BST)

Hi Ben,

On Wed, 2 Sep 2009, Ben Okopnik wrote:

>> If anyone has any comments/advice on the HTTP it spits out, feel free to
>> educate me.
>
> Well, let's see:
>
> ```
> ben@Jotunheim:~$ nc www.franjam.org.uk 80
> GET /index.html HTTP/1.1
>
> HTTP/1.0 404 Not Found.
> Server: MickyMouse0.1
> Date: Wed, 02 Sep 2009 22:02:03 +0000
> Connection: close
> Content-Type: text/html; charset=ASCII
>
> <html><head>
> <title>Not Found</title>
> <h2>43.sub-75-202-207.myvzw.com (75.202.207.43) requested <b><em>/index.html</em></b></h2>
> <h2>Page Not Found.</h2>
> </body></html>
> '''
>
> I'm not 100% sure, but I don't believe that 'charset=ASCII' is a valid
> charset string (although 'charset="us-ascii"' is.) You should also send
> a DTD spec, i.e.
>
> ``
> <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
> <html><head>
> ...
> ''
>
> and so on.

ok thanks for that. Appreciated.

Jim


Top    Back


Neil Youngman [Neil.Youngman at youngman.org.uk]


Thu, 3 Sep 2009 06:19:08 +0100

On Wednesday 02 September 2009 22:55:41 Jim Jackson wrote:

> If anyone has any comments/advice on the HTTP it spits out, feel free to
> educate me.

The W3C validator knows more about (X)HTML than I ever will. If you ask it nicely, it will teach you.

https://validator.w3.org/check?uri=www.fr[...]atically)&doctype=Inline&group=0

Neil Youngman


Top    Back


Jim Jackson [jj at franjam.org.uk]


Fri, 4 Sep 2009 10:59:04 +0100 (BST)

On Thu, 3 Sep 2009, Neil Youngman wrote:

> On Wednesday 02 September 2009 22:55:41 Jim Jackson wrote:
>> If anyone has any comments/advice on the HTTP it spits out, feel free to
>> educate me.
>
> The W3C validator knows more about (X)HTML than I ever will. If you ask it
> nicely, it will teach you.
>
> https://validator.w3.org/check?uri=www.fr[...]atically)&doctype=Inline&group=0
>

Yes, I should use that. Thanks. Does it only validate HTML? I'm also concerned about the HTTP headers.

Jim


Top    Back


Neil Youngman [Neil.Youngman at youngman.org.uk]


Fri, 4 Sep 2009 11:07:05 +0100

On Friday 04 September 2009 10:59:04 Jim Jackson wrote:

> On Thu, 3 Sep 2009, Neil Youngman wrote:
> > The W3C validator knows more about (X)HTML than I ever will. If you ask
> > it nicely, it will teach you.
> >
> > https://validator.w3.org/check?uri=www.franjam.org.uk&charset=(detect+auto
> >matically)&doctype=Inline&group=0
>
> Yes, I should use that. Thanks.
> Does it only validate HTML? I'm also concerned about the HTTP headers.

I don't know of any tools that validate the HTTP headers and a quick Google doesn't come up with anything useful.

Neil


Top    Back


Ben Okopnik [ben at linuxgazette.net]


Fri, 4 Sep 2009 08:57:30 -0500

On Fri, Sep 04, 2009 at 11:07:05AM +0100, Neil Youngman wrote:

> On Friday 04 September 2009 10:59:04 Jim Jackson wrote:
> > On Thu, 3 Sep 2009, Neil Youngman wrote:
> > > The W3C validator knows more about (X)HTML than I ever will. If you ask
> > > it nicely, it will teach you.
> > >
> > > https://validator.w3.org/check?uri=www.franjam.org.uk&charset=(detect+auto
> > >matically)&doctype=Inline&group=0
> >
> > Yes, I should use that. Thanks.
> > Does it only validate HTML? I'm also concerned about the HTTP headers.
> 
> I don't know of any tools that validate the HTTP headers and a quick Google 
> doesn't come up with anything useful. 

If you go to the W3C site and look up Content-type headers, you'll learn more about it than you ever wanted to. It's not very complex, actually: all that's actually required is

Content-type: text/html\n\n

(the two "\n"s, or "\n\r"s at the end are critically important!) - but there's more stuff you can do to inform the browser of your server's HTTP protocol level, the charset you're using, etc.

-- 
* Ben Okopnik * Editor-in-Chief, Linux Gazette * https://LinuxGazette.NET *


Top    Back


Anderson Silva [afsilva at gmail.com]


Fri, 4 Sep 2009 09:28:22 -0400

i also use firefox plugin called Live HTTP Headers to study and investigate issues with headers.

google for it, to download it.

AS

Sent from my iPhone


Top    Back


Jim Jackson [jj at franjam.org.uk]


Fri, 4 Sep 2009 16:16:03 +0100 (BST)

On Fri, 4 Sep 2009, Anderson Silva wrote:

> i also use firefox plugin called Live HTTP Headers to study and investigate 
> issues with headers.
>
> google for it, to download it.

I searched addons.mozilla.org - a bit safer - and installed, thanks for the tip.

Jim


Top    Back


Jim Jackson [jj at franjam.org.uk]


Fri, 4 Sep 2009 16:20:44 +0100 (BST)

On Fri, 4 Sep 2009, Ben Okopnik wrote:

> On Fri, Sep 04, 2009 at 11:07:05AM +0100, Neil Youngman wrote:
>> On Friday 04 September 2009 10:59:04 Jim Jackson wrote:
>>> On Thu, 3 Sep 2009, Neil Youngman wrote:
>>>> The W3C validator knows more about (X)HTML than I ever will. If you ask
>>>> it nicely, it will teach you.
>>>>
>>>> https://validator.w3.org/check?uri=www.franjam.org.uk&charset=(detect+auto
>>>> matically)&doctype=Inline&group=0
>>>
>>> Yes, I should use that. Thanks.
>>> Does it only validate HTML? I'm also concerned about the HTTP headers.
>>
>> I don't know of any tools that validate the HTTP headers and a quick Google
>> doesn't come up with anything useful.
>
> If you go to the W3C site and look up Content-type headers, you'll learn
> more about it than you ever wanted to. It's not very complex, actually:
> all that's actually required is
>
> ```
> Content-type: text/html\n\n
> '''
>
> (the two "\n"s, or "\n\r"s at the end are critically important!)

actually just to make clear, the double "\n"s, or "\n\r"s are only needed after the last http header. In Ben's example, I think he means that it is the only header, and hence the last one. Like smtp (email), http says there must be an empty line between the headers and the content.

cheers Jim


Top    Back


Ben Okopnik [ben at linuxgazette.net]


Fri, 4 Sep 2009 13:55:26 -0500

On Fri, Sep 04, 2009 at 04:20:44PM +0100, Jim Jackson wrote:

> On Fri, 4 Sep 2009, Ben Okopnik wrote:
>
>> If you go to the W3C site and look up Content-type headers, you'll learn
>> more about it than you ever wanted to. It's not very complex, actually:
>> all that's actually required is
>>
>> ```
>> Content-type: text/html\n\n
>> '''
>>
>> (the two "\n"s, or "\n\r"s at the end are critically important!)
>
> actually just to make clear, the double "\n"s, or "\n\r"s are only needed 
> after the last http header. In Ben's example, I think he means that it is 
> the only header, and hence the last one. Like smtp (email), http says  
> there must be an empty line between the headers and the content.

I did say that was the required minimum. You're right about larger headers, however: any other header data, which can be very large indeed (think "Content-type: multipart/form-data", and "megabyte-sized attachments") must come before the required 'blank line'.

-- 
* Ben Okopnik * Editor-in-Chief, Linux Gazette * https://LinuxGazette.NET *


Top    Back


Paul Sephton [paul at inet.co.za]


Wed, 02 Sep 2009 18:45:10 +0200

Just thought I'd drop a line to say how much I enjoyed Ziemann's unbelievably well written article about setting up an "Internet Radio Router".

Great read.


Top    Back


Rick Moen [rick at linuxmafia.com]


Wed, 2 Sep 2009 10:07:40 -0700

Quoting Paul Sephton (paul@inet.co.za):

> Just thought I'd drop a line to say how much I enjoyed Ziemann's
> unbelievably well written article about setting up an "Internet Radio
> Router".
> 
> Great read.

It was a great read.

Remember, folks, one of the pleasures of being a copyeditor or technical reviewer for LG is that you get to be first to read pieces like that. (Anyway, thanks indeed to Volker Ziemann.)


Top    Back


Mulyadi Santosa [mulyadi.santosa at gmail.com]


Thu, 3 Sep 2009 08:18:48 +0700

On Thu, Sep 3, 2009 at 12:07 AM, Rick Moen<rick@linuxmafia.com> wrote:

> Quoting Paul Sephton (paul@inet.co.za):
>
>> Just thought I'd drop a line to say how much I enjoyed Ziemann's
>> unbelievably well written article about setting up an "Internet Radio
>> Router".
>>
>> Great read.
>
> It was a great read.
>
> Remember, folks, one of the pleasures of being a copyeditor or technical
> reviewer for LG is that you get to be first to read pieces like
> that. (Anyway, thanks indeed to Volker Ziemann.)

Looks like Mr Ziemann at least gets 3 votes (including from me) to be considered as "a good piece of article" :)

-- 
regards,


Top    Back