SPUG: Output files

Jafaar Nyang'oro seppy at mail.tanzatech.com
Tue Apr 3 22:02:25 CDT 2001


William,

No. You didn't miss a thread because no one had responded to
the question I had asked:

To further expand on the same logic. I'm getting the output
that's been generated by running an NT batch script. The batch
script does 'ftp' all the info out into two zip files, and
send them to an AIX box. 

Now, the script I'm creating is supposed to unzip the zip-ed
files once they get into the AIX box, then grab the 'sysinfo.out', 'dept.out', and 'contact.out' files from among a whole bunch of extracted files. Then convert them to look like files created by the UNIX  processes. And finally to 'tar.Z' the output files.

The problem I run into time and again is that all the NT files
contain the hostname as part of the filename. Since several
people would run this batch file on their machine, it's
evident that every zip file that would be ftp-ed to me would
have a different name (although they will all have the 
'_sysinfo.out','_dept.out', and '_contact.out' suffixes. 

So how do I tell my script to grab the appropriate filenames
without having to hard-code everything? I'm stuck in the mud
here.

For instance in this file 'DBWNT01_NTcontact.out', 'DBWNT01_NT'
is the hostname of the machine and 'contact.out' is the supposedly
filename. But I get the whole thing when the script runs. So how do I tell my script to grab that hostname info and add it into the file name. 

Do I make any sense here? I'm a bit confused.

  

Thanks.

../seppy


---------- Original Message ----------------------------------
From: William Rowden <rowdenw at eskimo.com>
Date: Mon, 2 Apr 2001 18:36:09 -0700 (PDT)

>Did I miss a thread?  I don't see that anyone has answered this
>question.  (I notice because I wait until the end of a thread to
>decide if I'll save its messages.  Few trim their replies, so the
>final message usually contains most of the thread.)
>
>On Mar 22, Jafaar Nyang'oro wrote:
>> I need to create a script that would format the output from
>> files created by processes running in Windows NT to look like
>> the output that has been created by UNIX processes.
>> 
>> I have included the files in question below. I'll appreciate for
>> any pointers on how to write that sort of a script. In all,
>> there are three files: sysinfo.out, contacts.out, and dept.out
>
>A straightforward--but perhaps not very clever--approach would be as
>follows:
>
>	1.  Write regular expressions for relevant information.
>	2.  Capture changing information in variables.
>	3.  Print new files by placing variables in standard text.
>
>> file: sysinfo.out
>> 
>> 
>> Run Date: Tue Mar 20 16:17:36 CST 2001
>> Operating System: SunOS
>
>A sample that prints in this format is below.  Hopefully your Perl
>executable isn't in the bizarre location mine is.
>
>-----8<-----
>#!/usr/local/bin/perl5 -w
>
>$dozfile = "nt-sysinfo.out";
>$nixfile = "sysinfo.out";
>
>open (NT, "< $dozfile\0") or
>    die "Can't open Windoze file $dozfile for reading: $!\n";
>open (NIX, "> $nixfile\0") or
>    die "Can't open *nix file $nixfile for reading: $!\n";
>
>while (<NT>) {
>    next if /^\s*$/;    # Ignore blank lines.
>    s/\s+$//;           # Remove trailing white space.
>    if (/^(\w{3} \w{3} \d{1,2} \d{2}:\d{2}:\d{2}) (\d{4})$/) {
>	$date = $1;
>	$year = $2;
>    }
>    elsif (/^NT Type: (.*)$/) {
>	$OS = $1;
>    }
>    # elsif etc.
>}
>
>print NIX <<EOF
>Run Date: $date CST $year
>Operating System: $OS
>EOF
># Include additional lines above the EOF.
>-----8<-----
>
>> file: contact.out
>
>This one looks the same to me.
>
>> file: dept.out
>> 
>> Department(s): 704dss
>
>What's different about this?
>
>> file: nt-sysinfo.out
>> 
>> Thu Mar 22 01:27:20 2001
>> NT Type: NT Advanced Server
>
>The REs above capture these.
>-- 
>    -William
>PGP key: http://www.eskimo.com/~rowdenw/crypt/pgp/rowdenw.asc
>Fingerprint: 00C9 6887 F073 A261 CE06  EC88 7D75 13BD 1221 2BA9
>I'm not left-handed either.
>
>
>
>
> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
>     POST TO: spug-list at pm.org       PROBLEMS: owner-spug-list at pm.org
>      Subscriptions; Email to majordomo at pm.org:  ACTION  LIST  EMAIL
>  Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address
> For daily traffic, use spug-list for LIST ;  for weekly, spug-list-digest
>  Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/
>
>
>

 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     POST TO: spug-list at pm.org       PROBLEMS: owner-spug-list at pm.org
      Subscriptions; Email to majordomo at pm.org:  ACTION  LIST  EMAIL
  Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address
 For daily traffic, use spug-list for LIST ;  for weekly, spug-list-digest
  Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/





More information about the spug-list mailing list