[comp.os.vms] Location Of a Running Program...

NEWCOMER@DICKINSN.BITNET ("Newcomer, Don") (07/16/88)

CS117030@YUSOL.BITNET writes:

>        I would like to know if there is any way that you could find
>     the location of a running program on the disk, because i would
>     like to put this code in a high level language program, and when
>     I run the program, it should give me the location where the
>     actual program is been stored, regardless of my default location.

Using SYS$GETJPI and the item JPI$_IMAGNAME will give you the full name of the
image being executed by any process.  That should do just what you want.

                                        Don Newcomer
                                        Dickinson College
                                        Carlisle PA  USA
                                        NEWCOMER@DICKINSN.BITNET

LUSGR@VAX1.CC.LEHIGH.EDU (STEVE ROSEMAN) (07/21/88)

> From: CS117030%YUSOL.BITNET@IBM1.CC.LEHIGH.EDU
> Subject: Location Of a Running Program...


>        I would like to know if there is any way that you could find
>     the location of a running program on the disk, because i would
>     like to put this code in a high level language program, and when
>     I run the program, it should give me the location where the
>     actual program is been stored, regardless of my default location.

Here is the beginning of a subroutine I use for that purpose.

Steve Roseman
Lehigh University.

-------

      SUBROUTINE PS_INIT
C
C..   INITIALIZATION OF OUTPUT FILE (PROLOG)
C
      CHARACTER UN*12, NODE*20, CDATE*10, CTIME*10, IMAGE*39
      include '($jpidef)'
C
      REWIND 99
1     FORMAT(A)
      WRITE(99,1) '%!PS-Adobe-1.0'
      WRITE(99,1) '%%DocumentFonts: Courier '
      WRITE(99,1) '%%Title: LUCC VAX/VMS Plot V1.0'
      j = lib$getjpi(jpi$_imagname,,,,image,i1)
      WRITE(99,1) '%%Creator: '//image(:i1)

jabir@quintus.uucp (Jabir Hussain) (07/30/88)

argv[0] for C programs usually has the entire file spec of the image.
I don't know where it gets it from, but if your HLL is C, you are all set.

main(argc,argv) int argc; char *argv[]; { printf("%s\n", argv[0]); }