C Program to execute programs in same console

cpghost cpghost at cordula.ws
Mon Apr 3 22:02:31 UTC 2006


On Mon, Apr 03, 2006 at 05:45:19PM -0400, Bill Moran wrote:
> On Mon, 3 Apr 2006 21:39:11 +0000
> "Jonathan Herriott" <herriojr at gmail.com> wrote:
> > So, my question is how can I get it to execute a cd in the current
> > shell using c code.  You don't have to give me the code, just give me
> > a term to search for or a function to look up.  I'm sure someone knows
> > how to do it here!
> 
> Unless I'm misunderstanding your question, "man 2 chdir" should help out.

Hmmm... chdir(2) would not change the parent process' (the shell's
process) current working directory, only the current working directory
of the process running the C program.

Perhaps connecting to the shell via a pty, and then sending it a 'cd'
command could work? Of look at how expect(1) (/usr/ports/lang/expect)
implements this kind of stuff...

Regards,
-cpghost.

-- 
Cordula's Web. http://www.cordula.ws/


More information about the freebsd-questions mailing list