From: Robert Klemme Date: 2008-09-29T20:48:10+09:00 Subject: Re: [working directory to be changed (in terminal) by the Ruby ] 2008/9/28 Max Dev : > I have a little problem... > > I created a script. At some point I should change from whatever > directory I'm currently in (in Terminal) to a certain directory from the > ruby script. > > So far I find other solutions that do not satisfy me. The one with which > I managed to change directories in the terminal needs another .sh file. > > When launching the .sh script from the terminal, actually changes the > directory (pwd). But if I launch from the ruby script, does not change > the output terminal (pwd). > > Then, I want the working directory to be changed (in terminal) by the > Ruby program after it exits. You do not explicitly state this but from what you write I assume you are on a Unix like OS. And you want to change a parent process's idea of CWD from a child process. In order to be able to do this your child process needs to communicate the new CWD to the parent in some form. One option is to write a shell function which executes the child process and changes directory according to that child process's output like (/bin/echo serves as the child process here): # bourne (again) shell mycd(){ cd "`/bin/echo '/'`" } You can as well use temporary files or other means to communicate this but you almost certainly need to do something in the parent shell. Kind regards robert -- remember.guy do |as, often| as.you_can - without end