changing dir inside shell

Dan Smith daniel at island.uu.net
Thu Jul 28 07:40:42 AEST 1988


In article <Jul.26.15.39.08.1988.28499 at topaz.rutgers.edu> ron at topaz.rutgers.edu (Ron Natalie) writes:
>You can't.  Directory changing is a per process thing.

	Well...you can, at least on BSD systems. I use a program that
will "type" its arguments to standard input (like a "cd foo" command).
I guess it would be analogous to "keyfake" or something of that type for
MsLoss. Ron's right technically - you just have to work around the
per-process limit! :-) Below is the source to "typein", written
by my friend David Vezie many moons ago. Posted with permission.
Try "typein date", and "typein date^M" (type control V control M)

				dan

-----------------------snip crumble chomp-----------------------------
/*
 * typein.c -- push it's arguments onto the standard input.
 * uses the TIOCSTI ioctl, and LPENDIN (turning off echo), so
 * it appears after the prompt.
 *
 * Copyright 1984, David Vezie.
 * Permission to copy unlimited granted, providing this message
 * stays with the source
 * All other rights reserved (unless all lawyers are shot :-).
 */
#include <stdio.h>
#include <sgtty.h>

main(argc, argv)
	int argc;
	char **argv;
{
	register char *cp;
	struct sgttyb stb, stb2;
	int pendin = LPENDIN;

	ioctl(2, TIOCGETP, &stb);
	stb2 = stb;
	stb.sg_flags &= ~ECHO;
	ioctl(2, TIOCSETN, &stb);
	for (argc--, argv++; argc > 0; argc--, argv++) {
		for (cp = *argv; cp && *cp; cp++)
			ioctl(2, TIOCSTI, cp);
		if (argc > 1)
			ioctl(2, TIOCSTI, " ");
	}
	ioctl(2, TIOCSETN, &stb2);
	ioctl(2, TIOCLBIS, &pendin);
	exit(0);
}
----------------------------------------------------------------------
-- 
dan smith, island graphics, marin co, ca| +1 (415) 491 1000(W), 332 FAST(H)
4000 civic center dr, san rafael 94903  | dis: they're solely my opinions
daniel at island.uu.net {ucbvax!ucbcad,sun}!island!daniel pacbell!unicom!daniel
I'd rather have Roosevelt in a wheelchair, than Reagan & Bush on a horse -Jesse



More information about the Comp.unix.questions mailing list