[Thread Prev][Thread Next][Index]

Re: process ID, collisions

Hi Andrew,

In Ferret V5.4x you can grab the return text from a Unix shell command in a
string variable.  For your example you might use

    yes? LET pid = {SPAWN:"echo $$"}
    yes? SAVE/FILE=tmp.`pid`  ...

Note that in Ferret 5.33 I believe the capability existed in undocumented
form, but the keyword was SYSTEM instead of SPAWN.

    - steve


Andrew Wittenberg wrote:

> Wondering if anyone's come up with a robust and collision-free way to
> create temporary files in Ferret.  In particular, it'd be great to have a
> way to obtain the process identification (PID) of the Ferret session. For
> example, in shell scripting it's customary to create temporary files like
>    /tmp/$com:tmp.$$
> This way the temporary file is definitely (1) in a writeable directory,
> (2) traceable to its calling script, (3) identified as a temporary file,
> and (4) uniquely identified by its PID to avoid collisions with other
> users running the same script.
> I tried something like
>   spawn echo $$
> but this appears to echo the PID of the spawned subshell, not the parent
> Ferret process.  Anybody know how to get hold of the Ferret PID?  I
> suppose one could do it with a wrapper around the executable -- any other
> ideas?
> Thanks for your help,
> Andrew
> ----------------------------------------------------------------------
> Andrew Wittenberg          Program in Atmospheric and Oceanic Sciences
> andyw@splash.princeton.edu                        Princeton University
> ----------------------------------------------------------------------

Steve Hankin
NOAA/PMEL, 7600 Sand Point Way NE, Seattle, WA 98115-0070
ph. (206) 526-6080 -- FAX (206) 526-6744

[Thread Prev][Thread Next][Index]

Dept of Commerce / NOAA / OAR / PMEL / TMAP

Contact Us | Privacy Policy | Disclaimer | Accessibility Statement