Finding where an executable was run

Guy Harris guy at gorodish.Sun.COM
Sat May 21 04:23:38 AEST 1988


> I believe system V is different from BSD: argv[0] is always
> the full path name of the executable.

OK, time for some reality:

	argv[0] is always whatever the process that started up the program in
	question passed via the argument list.

This could be the full path name of the executable.  It could be the last
component of that path name.  It could be the first 10 words of the Magna
Carta.  It could be anything the program doing the "exec*" call wanted it to
be.

Thus, it's not a question of which version of the OS you're running.  It's a
question of what program fired up the executable.

I tried it under:

	the "previous" version of the Korn shell (i.e., pre-"ksh-i" - we don't
	have "ksh-i" *sigh*); it does not pass the full path name of the
	executable, but passes the name you typed (assuming no aliases, etc.).

	The SunOS 4.0 Bourne shell, based on the S5R3.1 Bourne shell; it does
	not pass the full path name of the executable, but passes the name you
	typed.

	The SunOS 4.0 C shell, based on the 4.3BSD C shell; it does not pass
	the full path name of the executable, but passes the name you typed.

	The 4.3BSD Bourne shell, based on the V7 Bourne shell; it does not pass
	the full path name of the executable, but passes the name you typed.

	The 4.3BSD C shell; it does not pass the full path name of the
	executable, but passes the name you typed.

	The System V Release 3.1 Bourne shell; it does not pass the full path
	name of the executable, but passes the name you typed.

I think there seems to be a pattern here....



More information about the Comp.unix.wizards mailing list