LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-23-2001, 11:54 PM   #1
rspenn
LQ Newbie
 
Registered: Feb 2001
Posts: 2

Rep: Reputation: 0
Exclamation


HI,

I'm new to this stuff and have searched hours but can't figure this one out and I'm sure someone knows this one.

I'm trying to add a date field to a web page on a Linux 6.2 box with apache 1.3. Under UNIX the path is usr/sbin/date to add the following:

Here is the command:
date_command = "/sbin/date";

$date = `$date_command +"%A, %B %d, %Y at %T (%Z)"`; chop($date);
$shortdate = `$date_command +"%D %T %Z"`; chop($shortdate);


Tuesday, January 30, 2001 at 17:22:00 (EST)

Any ideas?

 
Old 02-24-2001, 08:40 PM   #2
crabboy
Senior Member
 
Registered: Feb 2001
Location: Atlanta, GA
Distribution: Slackware
Posts: 1,821

Rep: Reputation: 121Reputation: 121
rspenn,

I'm not exactly sure what you are asking for in you post. I assume you are trying to write a perl script to display the date in a cgi script. Your date commands are correct, so I guess you need help to display them? The perl script below, using your date commands, display the date in a web page. If this is not the answer you were looking for then please supply more details... by the way... any executables in an sbin directory should never be executable by non privileged users. My date exec is under /bin

showdate.cgi:

#!/usr/bin/perl

$date_command = "/bin/date";
$date = `$date_command +"%A, %B %d, %Y at %T (%Z)"`; chop($date);
$shortdate = `$date_command +"%D %T %Z"`; chop($shortdate);

print "Content-type: text/html\n\n";
print "<HTML>";

print "$date\n";

print "</HTML>";
 
Old 02-24-2001, 09:32 PM   #3
rspenn
LQ Newbie
 
Registered: Feb 2001
Posts: 2

Original Poster
Rep: Reputation: 0
Smile Re: Date setting in Linux or Apache

You know, I feel real stupid, but looking over your script I realized that I was looking in /usr/bin not /bin so I couldn't find the date command. Really dumb, could have prevented a lot of stress and hours of digging. On the other hand, I did learn a lot in the search about other topics so not a loss.

Thanks for the Reply!
Ryan
 
Old 02-25-2001, 11:04 AM   #4
jeremy
root
 
Registered: Jun 2000
Distribution: Debian, Red Hat, Slackware, Fedora, Ubuntu
Posts: 13,602

Rep: Reputation: 4084Reputation: 4084Reputation: 4084Reputation: 4084Reputation: 4084Reputation: 4084Reputation: 4084Reputation: 4084Reputation: 4084Reputation: 4084Reputation: 4084
Perl has a bunch of builtin date stuff too. Something like this will also work:

Code:
print scalar(localtime);
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
setting time and date? maginotjr Slackware 7 06-28-2005 08:53 AM
setting date and time lynger Linux - Software 2 05-21-2004 12:10 AM
setting time and date trpn Linux - Software 5 11-07-2003 07:48 AM
Setting Date and Time prich Linux - Newbie 3 12-16-2002 02:28 PM
setting the date Nyc0n Linux - General 2 05-24-2002 02:56 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:30 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration