[JaxPM] Struggling
JONES, WILLIAM C
wcjones at exchange.fccj.org
Wed Dec 6 06:53:07 CST 2000
On the jacksonville-pm-list; Jax.PM'er "JONES, WILLIAM C" <wcjones at exchange.fccj.org> wrote -
try this on for size (you may need to fix email formatting errors):
#!/usr/bin/perl -w
# 'security.pl' - Perl script example showing how File Permissions work...
# written by Sneex, -IUDICIUM- on 15/Oct/98 @ 22:00...
# Use some specialized Perl Modules...
use strict;
use diagnostics;
use POSIX;
use IO;
# Get the date in the format of 'Sun Sep 6 18:04:46 1998'
my $ltDate = localtime;
# Now get the Serialized Date, and string'em back together...
my ($seconds, $minutes, $hour, $monthDate, $month,
$year, $weekDay, $yearDate, $daylightSavings) = localtime;
my $ltSerial =
"$seconds$minutes$hour$monthDate$month$year$weekDay$yearDate$daylightSavings"
;
# Name the output test file...
my $file = "test.File";
# Open it Write Only (O_WRONLY), in Append Mode (O_APPEND),
# if it already exists; otherwise Create the file (O_CREAT)
# Set the file permission bits to 0777 ( -rwxrwxrwx )
my $fh = new IO::File $file, O_WRONLY|O_APPEND|O_CREAT, 0777;
# Create specialized security marker.
# (This is just output as test data...)
if (defined $fh) {
print $fh "$ltSerial|$ltSerial|$ltDate\n";
undef $fh;
} else { print "Oops! Betcha that hurt: $!"; }
# Flush all I/O buffers...
autoflush STDOUT 1;
# Quit...
exit;
# The above quit is redundant as all perl scripts
# will automatically 'exit' (cleaning up behind
# themselves) when there is no more code to evaluate...
# NOTES:
#
# When the above is executed, it will create a
# file called 'test.File' in the current directory.
# Inside that file it will write some data which
# looks like this -
#
# 211221599842871|211221599842871|Thu Oct 15 22:01:21 1998
> ----------
> From: CGR Online
> Reply To: CGR Online
> Sent: Tuesday, December 5, 2000 9:53 PM
> To: jacksonville-pm-list at happyfunball.pm.org
> Subject: [JaxPM] Struggling
>
> On the jacksonville-pm-list; Jax.PM'er CGR Online <cgronline at jaxcan.org>
> wrote -
>
> use FileHandle;
>
> $fh = new FileHandle "> datafile";
> $mode = 0777; chmod $mode, 'datafile';
>
Jax.PM Moderator's Note:
This message was posted to the Jacksonville Perl Monger's Group listserv.
The group manager can be reached at -- owner-jacksonville-pm-list at pm.org
to whom send all praises, complaints, or comments...
More information about the Jacksonville-pm
mailing list