home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / os / vms / 12863 < prev    next >
Encoding:
Internet Message Format  |  1992-07-28  |  2.9 KB

  1. Path: sparky!uunet!cis.ohio-state.edu!ucbvax!GENVAX.COMPUTER-CENTRE.POLY-OF-WALES.AC.UK!AWOSBORNE
  2. From: AWOSBORNE@GENVAX.COMPUTER-CENTRE.POLY-OF-WALES.AC.UK
  3. Newsgroups: comp.os.vms
  4. Subject: help with C/fortran and LIB$SPAWN problem
  5. Message-ID: <9207282033.AA18527@ucbvax.Berkeley.EDU>
  6. Date: 28 Jul 92 17:26:00 GMT
  7. Sender: daemon@ucbvax.BERKELEY.EDU
  8. Distribution: world
  9. Organization: The Internet
  10. Lines: 101
  11.  
  12.  
  13.     Hi everybody,
  14.  
  15.     Basically this request is about using FORTRAN or C to get the
  16.     name of the DCL script within which a the program is being run.
  17.  
  18.  
  19.     A few months ago a request came onto the net for a means of
  20.     getting the name of a command file from within which a H.L.L
  21.     program is being run, as DCL's f$environment("procedure") does.
  22.  
  23.     The general concensus was that it couldn't be done with the
  24.     present collection of library and system routines.
  25.     A macro program was then mailed which managed to return the
  26.     command-file name (well done whoever!).
  27.  
  28.     As I don't have any experience of MACRO and want a solution that
  29.     can work across VMS versions, I tried a different approach
  30.     ( and failed ! 8-( )
  31.  
  32.  
  33.     Here's my failed attempt:
  34.  
  35.     Within a DCL script, you could spawn a command such as the
  36.     following:
  37.  
  38. $spawn define envfile1 'f$environment("procedure")'/table=lnm$job
  39.  
  40.     which places the DCL script-name into a logical - great !
  41.  
  42.  
  43.     I would like to do this from within FORTRAN or C during its
  44.     (not before, which a user can fake) for later reading, and
  45.     tried the following:
  46.  
  47.     PROGRAM TEST
  48.     IMPLICIT NONE
  49.  
  50.     CHARACTER*40    COMM1/'def envfile1 testmsg/table=lnm$job'/
  51.     CHARACTER*70    COMM2/'def envfile2 ''f$environment("procedure")''
  52.     1/TABLE=LNM$job'/
  53.  
  54.     INTEGER*4    STATUS,
  55.     1        LIB$SPAWN
  56.  
  57. !    This is the test DEFINE with a simple string
  58.     PRINT *,COMM1
  59.  
  60. !    This is the DEFINE string that doesn't work
  61.     PRINT *,COMM2
  62.  
  63.     STATUS=LIB$SPAWN(comm1)
  64.     IF (.NOT. STATUS) CALL LIB$SIGNAL(%VAL(STATUS))
  65.  
  66.     STATUS=LIB$SPAWN(comm2)
  67.     IF (.NOT. STATUS) CALL LIB$SIGNAL(%VAL(STATUS))
  68.  
  69.     END
  70.  
  71.  
  72.     Unfortunately, the first spawned DEFINE worked,
  73.     BUT the second spawned DEFINE didn't,
  74.     returning the following mesages:
  75.  
  76. V86_ena> @do        ! my command file which runs the above program
  77. def envfile1 testmsg/table=lnm$job      
  78. def envfile2 'f$environment("procedure")'/TABLE=LNM$job               
  79. %DCL-W-NULFIL, missing or invalid file specification - respecify
  80. V86_ena> sho log env*
  81.  
  82. (LNM$PROCESS_TABLE)
  83.  
  84. (LNM$JOB_83496D10)
  85.  
  86.   "ENVFILE1" = "TESTMSG"
  87.  
  88. (LNM$GROUP_000020)
  89.  
  90. (LNM$SYSTEM_TABLE)
  91.  
  92. (DECW$LOGICAL_NAMES)
  93.  
  94.  
  95.     Can anybody point me in the right direction for passing the
  96.     DEFINE ENVFILE 'F$ENVIRONMENT("PROCEDURE")' command-line
  97.     using SPAWN from within FORTRAN or C, and getting it to store
  98.     the DCL script-name in which it's being run ?. It appears to
  99.     be tripping over the single quotes - any work-arounds ?
  100.  
  101.  
  102.     We're on VMS 5.4_2 and I used Fortran version 5.6 for the
  103.     above test.
  104.     Hope somebody can help ...
  105.  
  106.  
  107.             Nye Osborne.
  108.  
  109.                 Polytechnic of Wales (POW)
  110.                 soon to be:
  111.                 University of Glamorgan (UG) Yuk !            
  112.  
  113.