<180 at sdcsla.UUCP> (help on $cdpath)

Wolfgang Thomeier wolf at garfield.UUCP
Tue Dec 6 01:31:24 AEST 1983


I am posting this to the net at the request of a friend of mine.
Please mail any responses to this to me and I will forward it
through the proper channels.

-----------------------------------------------------------------
With reference to cdpath you might try one of the following .....
This is not the actual login shells variable but it will give the
cdpath of a csh that you start up.

main()
{
	int topipe[2];
	char temp[256];

	pipe( topipe );
	if ( fork() == 0 ) {
		dup2( topipe[1], 1);
		close( topipe[0] );
		close( topipe[1] );
		execl("/bin/csh","pwd","-c","echo $cdpath");
	}
	close( topipe[1] );
	read( topipe[0], temp, sizeof(temp) );
	close( topipe[0] );
	printf("%s", temp);
}

----------------------------------------------------------------

				OR

----------------------------------------------------------------
#include <stdio.h>

main()
{
	FILE *pwd,*popen();
	char temp[256];

	pwd = popen("csh -c 'echo $cdpath' ", "r");
	fread( temp, sizeof( temp ), 1, pwd );
	printf("%s\n", temp );
}
----------------------------------------------------------------
End of forwarded article

UUCP:			{allegra, ihnp4, utcsrgv}!garfield!wolf

In real life:		Wolfgang Thomeier
			Memorial University of Newfoundland
			St. John's, NF



More information about the Comp.lang.c mailing list