MU-VMS Archives

November 1996

MU-VMS@LISTSERV.MIAMIOH.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Kent Covert <[log in to unmask]>
Reply To:
Miami University OpenVMS <[log in to unmask]>
Date:
Tue, 5 Nov 1996 08:12:34 -0500
Content-Type:
text/plain
Parts/Attachments:
text/plain (62 lines)
In article <[log in to unmask]>, [log in to unmask]
 (Chris Carman) writes:
> In article <[log in to unmask]>, [log in to unmask]
 (Randy Kaelber) writes:
>> Chris Carman ([log in to unmask]) wrote:
>>> Shouldn't the process ID change every time it's run?  Basically, all I want
 is
>>> a unique number every time this script I'm working on is run, and although
 it
>>> wouldn't be a problem to put in a little counter subroutine, I just figured
 a
>>> process ID would be easier.  Any ideas?  Thanks!
>>
>> What you're up against is OpenVMS, unlike the UNIX variants, does not fork
>> a new process everytime you run a command. So, you're getting the process
>> ID of your DCL process. Before we can address what you need to do instead,
>
> Ah, okay.
>
>> what is that that you're wanting to accomplish with the unique number?
>
> Well, I have a workaround, but what I wanted to do was create a unique data
> file every time a script is run.  This one way I got around it:
>
> open(PID,"show process/dump|");
>    $line=<PID>; $line=<PID>;
>    $file = substr($line,0,23);
>    $file =~ s/\ //g;
>    $file =~ s/\:/-/g;
>    $line=<PID>; $line=<PID>; $line=<PID>;
> close (PID);
>
> This just results in a filename like 4-NOV-199615-04-56.41, which is as close
> to unique as I can get.  Anyway, it didn't work out; I'm having prolems
> getting a script to send a mail message right now.
 
Using the open() function above is not very efficient, because it causes a
subprocess to be created (a rather inefficient operation on VMS).  What if
you did something like the following:
 
    $file = time() . ".dat";
 
the time() function returns the number of seconds since January 1, 1970.
As long as your routine isn't run twice in the same second, this should be
fairly unique (and efficient).
 
If you want to send mail from Perl on VMS, the easiest way is to do the
following:
 
1) Create a file that contains your mail message (we'll assume you called
it letter.txt).
 
2) Issue the following Perl command:
 
    system('MAIL LETTER.TXT "[log in to unmask]"/subject="subject"');
 
--
                                     Kent Covert, Software Coordinator
                                     Miami Computing and Information Services
                                     Miami University, Oxford, OH
                                     [log in to unmask]

ATOM RSS1 RSS2