From owner-freebsd-questions Mon Mar 25 11:12:24 2002 Delivered-To: freebsd-questions@freebsd.org Received: from tninet.se (lennier.tninet.se [195.100.94.105]) by hub.freebsd.org (Postfix) with ESMTP id EEFA937B477 for ; Mon, 25 Mar 2002 11:09:25 -0800 (PST) Received: from cs.umu.se (h27n1c1o1023.bredband.skanova.com [213.64.164.27]) by lennier.tninet.se (BMR ErlangTM/OTP 3.0) with ESMTP id 417769.83080.1017.0s14480044lennier ; Mon, 25 Mar 2002 20:04:40 +0100 Message-ID: <3C9F74C8.9165C0F1@cs.umu.se> Date: Mon, 25 Mar 2002 20:04:40 +0100 From: Paul Everlund X-Mailer: Mozilla 4.77 [en] (Windows NT 5.0; U) X-Accept-Language: sv,en MIME-Version: 1.0 To: Drew Tomlinson Cc: Dan Nelson , Walter Hop , smorton@acm.org, questions@FreeBSD.ORG Subject: Re: Showing Uptime Via webpage References: <3C9E0754.2010104@verizon.net> <006201c1d423$ee01be00$f82a6ba5@lc.ca.gov> <200203251840.33315@silver.dt1.binity.net> <007a01c1d426$38b2c410$f82a6ba5@lc.ca.gov> <20020325182247.GD14939@dan.emsphone.com> <008401c1d42d$7ad8f420$f82a6ba5@lc.ca.gov> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Drew Tomlinson wrote: > > ----- Original Message ----- > From: "Dan Nelson" > To: "Drew Tomlinson" > Cc: "Walter Hop" ; ; > > Sent: Monday, March 25, 2002 10:22 AM > Subject: Re: Showing Uptime Via webpage > > > > > [in reply to Drew Tomlinson, Monday 25 March 2002 18:38] > > > > > > > > > > #!/usr/bin/perl > > > > > > print "Content-type: text/plain\n\n"; > > > > > > system ("uptime"); > > > > > > exit; > > > > > > > > > > I tried this just out of curiosity but ran into problems. I > don't > > > get > > > > > any errors but I just get a blank web page. > > > > > > > > What happens if you run "/usr/bin/uptime" instead of "uptime"? > > > > > > Thanks for your suggestion. However, "/usr/bin/uptime" makes no > > > difference. The page is still blank. > > > > Can you print any data at all? Note that you are generating an > > incorrect HTML header; the spec says you must use CRLFs, and some > > proxies/browsers may refuse to parse the page. > > I'm not sure exactly what you mean by "..print any data...". My web > server shows my static pages just fine. I have a test script that I > picked up somewhere along the way to test that cgi is working and that > prints data on a web page. And if I run the script from the command > line, I get this output: > > blacklamb# ./uptime > Content-type: text/plain > > 9:56AM up 1 day, 44 mins, 1 user, load averages: 0.00, 0.00, 0.00 > > I'm sorry if I'm being real dense here but I have no experience with > perl and very, very little in designing web pages without the help of > (gasp) FrontPage but I'm trying to learn. > > So I assume that the \n is either a CR or and LF and I need \something > else to conform to the spec? I was just using and example that was > posted previously. > > Thanks for your help. > > Drew What happens if you change the header from printing Content-type: text/plain to Content-type: text/html: #!/usr/bin/perl print "Content-type: text/html\n\n"; system("uptime"); Does this work? Best regards, Paul To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message