CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
`date` not working on server

 



Exuro
New User

Nov 20, 2004, 10:27 PM

Post #1 of 6 (1282 views)
`date` not working on server Can't Post

I've recently installed ActivePerl on my WinXP machine running IIS v5.1. I'm just starting to learn perl, and I'm having trouble getting a script I have to properly display when I access it via the web.

Here's the content of testing.pl:


Code
print "Content-type: text/html\n\n"; 
print "The current date is: ";
print `date /T`;



I get the proper output when running the script through perl.exe via command prompt:


Quote
Content-type: text/html

The current date is: Sat 11/20/2004


But when I visit the page in my browser all I see is "The current date is: ". Is the ability to execute external programs and get output from them disabled by IIS for security purposes, or am I just doing something wrong? Thanks!


benn600
User


Nov 21, 2004, 7:35 PM

Post #2 of 6 (1273 views)
Re: [Exuro] `date` not working on server [In reply to] Can't Post

I use date on my website as well (in my signature) but I didn't use what you used. I forget where I actually got the text but here is part of it:

($sec,$min,$hr,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);

@days = ("Sun","Mon","Tue","Wed","Thur","Fri","Sat");

$year = $year + 1900;

$currentdate = "$days[wday] $mday/$mon/$year";
print "$currentdate";

This should give you what you are looking for but it is a little more complicated. It works for me and I set it up to do just what you wanted. I hope everything works out right!
----------------------------------------------------------------------------
Wink http://www.ppcpathways.com/ Wink
Visit my new site devoted to reviewing the latest pocketpc products and news that I built in cgi-perl!


Exuro
New User

Nov 21, 2004, 7:40 PM

Post #3 of 6 (1271 views)
Re: [benn600] `date` not working on server [In reply to] Can't Post

Sorry, but that's really not what I was asking about... I have no particular interest in the date COM command, I'm just wondering why the backticks arn't working as they're described in the NCSA's tutorial:
http://archive.ncsa.uiuc.edu/General/Training/PerlIntro/strings.html


benn600
User


Nov 21, 2004, 7:42 PM

Post #4 of 6 (1269 views)
Re: [Exuro] `date` not working on server [In reply to] Can't Post

Oh...well sorry, I don't have any idea about those and I have never used them, that I can think of.
----------------------------------------------------------------------------
Wink http://www.ppcpathways.com/ Wink
Visit my new site devoted to reviewing the latest pocketpc products and news that I built in cgi-perl!


davorg
Thaumaturge / Moderator

Nov 22, 2004, 2:04 AM

Post #5 of 6 (1263 views)
Re: [Exuro] `date` not working on server [In reply to] Can't Post

I don't know why that approach wouldn't work on IIS, but I'd strongly recommend using Perl's build-in ways for getting the date (time, localtime and POSIX::strftime in particular) instead of calling an external program.

--
Dave Cross, Perl Hacker, Trainer and Writer
http://www.dave.org.uk/
Get more help at Perl Monks


davorg
Thaumaturge / Moderator

Nov 22, 2004, 2:20 AM

Post #6 of 6 (1261 views)
Re: [benn600] `date` not working on server [In reply to] Can't Post

That code's not as efficient as it could be, try something like this:


Code
my ($mday, $mon, $year, $wday) = (localtime)[3 .. 6]; 
my @days = qw(Sun Mon Tue Wed Thu Fri Sat);

$year += 1900;

print "$days[$wday] $mday/$mon/$year";


But actually, it all gets a _lot_ easier with POSIX::strftime;


Code
use POSIX 'strftime'; 
print strftime '%a %d/%m/%Y', localtime;


--
Dave Cross, Perl Hacker, Trainer and Writer
http://www.dave.org.uk/
Get more help at Perl Monks

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives