Sponsored Content
Full Discussion: CENTOS - istat
Operating Systems Linux Red Hat CENTOS - istat Post 302925361 by derekludwig on Sunday 16th of November 2014 07:44:33 PM
Old 11-16-2014
Many scripting languages can give you the information that istat provides, but I am not sure why you need to save the information to two new files ... but it is your script. For a perl replacement:
Code:
use strict;
use warnings;

use File::Basename;
use POSIX qw{ strftime };

$, = '';
$\ = "\n";

my $NAME = basename $0;

unless (0 < @ARGV) {
    print STDERR 'Usage: ', $NAME, ' <file> <mtimefile> <ownerfile>';
    exit 1;
}

my $file = shift @ARGV;
my @F = stat $file;

unless (0 < @F) {
    print STDERR $file, ': no such file or directory';
    exit 1;
}

$file = shift @ARGV;

open FH, '>', $file or die $file;
print FH strftime '%Y%m%d%H%M', localtime $F[9];
close FH;

$file = shift @ARGV;
open FH, '>', $file or die $file;
print FH $F[4], '(', scalar getpwuid($F[4]), ')';
close FH;

exit 0;

Which give you:
Code:
$ perl istatinfo istatinfo mtime owner
$ cat mtime
201411161938
$ cat owner
1002(derek)

for the file:
Code:
$ ls -l istatinfo
-rw-r--r--. 1 derek ludwig 588 Nov 16 19:38 istatinfo

Please format the mtime and owner to your liking.

Last edited by derekludwig; 11-16-2014 at 08:45 PM.. Reason: typo
 

6 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

HP LC2000 has message: istat=0a: LSS_PAR on ha=1 sist0=41

I have a HP Netserver 2000 running SCO UNIX 5.0.6. I get the message: istat=0a: LSS_PAR on ha=1 sist0=41 sist1=00 !!!! dstat =81 on ha=1 has DS_OPC while WAIT DISCONNECT, rp=c014f8co dsp=FD on path=1, newdsp=FD064600 WARNING: Parity Error MSG OUT=00000006 Failed, 1code=80000002 on ha=1 id... (0 Replies)
Discussion started by: dmksh
0 Replies

2. UNIX for Advanced & Expert Users

istat ??

I got the command : istat filename shows all the file details like owner and group name. But i want to know, who has accessed the file last time. As istat shows the name of owner of that file and name of the group. istat does lots of my work but i want to know who has accessed my file... (0 Replies)
Discussion started by: varungupta
0 Replies

3. UNIX for Advanced & Expert Users

istat ??

I got the command : istat filename shows all the file details like owner and group name. But i want to know, who has accessed the file last time. As istat shows the name of owner of that file and name of the group. istat does lots of my work but i want to know who has accessed my file... (2 Replies)
Discussion started by: varungupta
2 Replies

4. Shell Programming and Scripting

reformat date from istat

I would like to determine if a file is older than a particular date. I found that istat will let me see the date and time of a file older than a year, but I need to change the format. Could anyone help me reformat the following date to a variable (a one liner would be great). Output from istat -... (1 Reply)
Discussion started by: oldman2
1 Replies

5. Red Hat

How to Upgrade Centos 5.7 using Centos 5.8 ISO image on Vmware workstation

Dear Linux Experts, On my windows 7 desktop with the help of Vmware workstation (Version 7.1), created virtual machine and installed Centos 5.7 successfully using ISO image. Query : Is this possible to upgrade the Centos 5.7 using Centos 5.8 ISO image to Centos version 5.8?.. if yes kindly... (2 Replies)
Discussion started by: Ananthcn
2 Replies

6. Red Hat

RH V Centos

Hi, I have built out a new virtual production environment (VMWare, HA enabled, VMotion... all the bells & whistles) using RHEL5 VM's. I have got another ESX host that I plan to use as a pre-prod environment. To save some costs on RH subs I was thinking about installing this environment... (5 Replies)
Discussion started by: Duffs22
5 Replies
Parse::MediaWikiDump::Revisions(3pm)			User Contributed Perl Documentation		      Parse::MediaWikiDump::Revisions(3pm)

NAME
Parse::MediaWikiDump::Revisions - Object capable of processing dump files with multiple revisions per article ABOUT
This object is used to access the metadata associated with a MediaWiki instance and provide an iterative interface for extracting the indidivual article revisions out of the same. To gurantee that there is only a single revision per article use the Parse::MediaWikiDump::Revisions object. SYNOPSIS
$pmwd = Parse::MediaWikiDump->new; $revisions = $pmwd->revisions('pages-articles.xml'); $revisions = $pmwd->revisions(*FILEHANDLE); #print the title and id of each article inside the dump file while(defined($page = $revisions->next)) { print "title '", $page->title, "' id ", $page->id, " "; } STATUS
This software is being RETIRED - MediaWiki::DumpFile is the official successor to Parse::MediaWikiDump and includes a compatibility library called MediaWiki::DumpFile::Compat that is 100% API compatible and is a near perfect standin for this module. It is faster in all instances where it counts and is actively maintained. Any undocumented deviation of MediaWiki::DumpFile::Compat from Parse::MediaWikiDump is considered a bug and will be fixed. METHODS
$revisions->new Open the specified MediaWiki dump file. If the single argument to this method is a string it will be used as the path to the file to open. If the argument is a reference to a filehandle the contents will be read from the filehandle as specified. $revisions->next Returns an instance of the next available Parse::MediaWikiDump::page object or returns undef if there are no more articles left. $revisions->version Returns a plain text string of the dump file format revision number $revisions->sitename Returns a plain text string that is the name of the MediaWiki instance. $revisions->base Returns the URL to the instances main article in the form of a string. $revisions->generator Returns a string containing 'MediaWiki' and a version number of the instance that dumped this file. Example: 'MediaWiki 1.14alpha' $revisions->case Returns a string describing the case sensitivity configured in the instance. $revisions->namespaces Returns a reference to an array of references. Each reference is to another array with the first item being the unique identifier of the namespace and the second element containing a string that is the name of the namespace. $revisions->namespaces_names Returns an array reference the array contains strings of all the namespaces each as an element. $revisions->current_byte Returns the number of bytes that has been processed so far $revisions->size Returns the total size of the dump file in bytes. EXAMPLE
Extract the article text of each revision of an article using a given title #!/usr/bin/perl use strict; use warnings; use Parse::MediaWikiDump; my $file = shift(@ARGV) or die "must specify a MediaWiki dump of the current pages"; my $title = shift(@ARGV) or die "must specify an article title"; my $pmwd = Parse::MediaWikiDump->new; my $dump = $pmwd->revisions($file); my $found = 0; binmode(STDOUT, ':utf8'); binmode(STDERR, ':utf8'); #this is the only currently known value but there could be more in the future if ($dump->case ne 'first-letter') { die "unable to handle any case setting besides 'first-letter'"; } $title = case_fixer($title); while(my $revision = $dump->next) { if ($revision->title eq $title) { print STDERR "Located text for $title revision ", $revision->revision_id, " "; my $text = $revision->text; print $$text; $found = 1; } } print STDERR "Unable to find article text for $title " unless $found; exit 1; #removes any case sensativity from the very first letter of the title #but not from the optional namespace name sub case_fixer { my $title = shift; #check for namespace if ($title =~ /^(.+?):(.+)/) { $title = $1 . ':' . ucfirst($2); } else { $title = ucfirst($title); } return $title; } LIMITATIONS
Version 0.4 This class was updated to support version 0.4 dump files from a MediaWiki instance but it does not currently support any of the new information available in those files. perl v5.10.1 2010-12-05 Parse::MediaWikiDump::Revisions(3pm)
All times are GMT -4. The time now is 02:37 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy