home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!noc.near.net!bigboote.WPI.EDU!bigboote.wpi.edu!john
- From: john@sekrit.WPI.EDU (John Stoffel)
- Newsgroups: comp.lang.perl
- Subject: Re: stat problem
- Date: 6 Jan 93 11:48:43
- Organization: Worcester Polytechnic Institute
- Lines: 50
- Message-ID: <JOHN.93Jan6114843@sekrit.WPI.EDU>
- References: <jwh2.4.0@cornell.edu>
- NNTP-Posting-Host: sekrit.wpi.edu
- In-reply-to: jwh2@cornell.edu's message of Wed, 6 Jan 1993 15:10:16 GMT
-
- >>>>> On Wed, 6 Jan 1993 15:10:16 GMT, jwh2@cornell.edu (James W. Howell) said:
- James> Nntp-Posting-User: @cornell.edu
-
- James> Using the below perl script the stat routine doesn't return
- James> anything, has anyone seen this type of behavior before??? Jim
- James> Howell
-
- I played around with this for a bit before i figured out that stat()
- wants the FULL path to the file before it will work. All you have to
- do is make two simple changes to your program.
-
- James> #!/usr/bin/perl
- James> $usr_spool_dir = "/usr/include/";
- ^
- Add the trailing slash to make it easier later on...
-
- James> # $usr_spool_dir = "/usr/spool/mail/jwhtest";
- James> # $usr_spool_dir = "./";
- James> opendir(SDIR,$usr_spool_dir);
- James> @dir_files = readdir(SDIR);
- James> closedir(SDIR);
- ^^^^^^^^^^^^^^^
-
- Moved this up here because it is 'safer' and makes more logical sense
- to have it here, right after you have finished reading in all the
- directory entries.
-
- James> $ct = 0;
- James> foreach $file (@dir_files) {
- James> if( -d $file) { next; }
- James> if( -B $file) { next; }
- James> $one_file[$ct] = $file;
-
- James> ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size) =
- stat($usr_spool_dir . $one_file[$ct]);
- ^^^^^^^^^^^^^^^^^
-
- This is the major change, adding in the full path to the file you want
- to stat.
-
- This should do the trick. Oh yeah, this was with Perl 4.035 running
- on a DECstation 3100 running Ultrix 4.3
-
- John
-
- --
- Youth of today! Join me in a mass rally for traditional mental attitudes!
- -------------------------------------------------------------------------------
- john@wpi.wpi.edu | Work Station Specialist | Worcester Polytechnic Institute
- John Stoffel | 508-831-5512 (work) | Worcester, MA 01609
-