-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: Monday, July 21, 2003 1:14 PM
To: Jaimee Spencer; '[EMAIL PROTECTED]'; [EMAIL PROTECTED]
Subject: RE: date


Please don't top post.

------------------------------------------------
On Mon, 21 Jul 2003 12:25:26 -0700, Jaimee Spencer <[EMAIL PROTECTED]>
wrote:

> Hello, Tim.
> 
> Try something like
> 
> #!/usr/bin/perl -w
> 
> use strict;
> 
> system("date");
> 

Don't use this method unless you know of a *very* good reason to do it.  

If you are going to shell out to get the date which you shouldn't in the
first place, at least use a full path to the command, check the return value
of system, and if you intend to use the date for anything other than
printing to stdout then you will want to use backticks instead of 'system'.

In general it is less portable, more error prone, slower, and insecure...

See Kevin's post for a better way.

http://danconia.org

Hello, once again.

  Wiggins is right in a way this is dangerous and you should check out
Kevin's post , I would be careful about using variables also,
as $file can contain something that will interpreted
by shell as an additional commands. For example $file might containt
something destructive as '; rm -rf /'.

If you specify a list than system() doesn't use shell and it's usage
is much safer:

    system('cat', $file);

This will try to only print file specified by $file variable no matter
what $file contains.

p.s
   Wiggins didn't you just top post?  :o)

> 
> -----Original Message-----
> From: Tim McGeary [mailto:[EMAIL PROTECTED]
> Sent: Monday, July 21, 2003 12:18 PM
> To: [EMAIL PROTECTED]
> Subject: date
> 
> 
> Is there anyway to get the date from the system in perl?
> 
> Tim
> 
> 
> 
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 

Reply via email to