From: Axel Etzold Date: 2008-09-29T19:00:36+09:00 Subject: Re: [working directory to be changed (in terminal) by the Ruby ] -------- Original-Nachricht -------- > Datum: Sun, 28 Sep 2008 10:20:03 +0900 > Von: Max Dev > An: ruby-talk@ruby-lang.org > Betreff: [working directory to be changed (in terminal) by the Ruby ] > 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. > > Any suggestions? > Thanks > -- > Posted via http://www.ruby-forum.com/. Dear Max, not quite sure whether I understand correctly what you want to do, but you should be able to perform everything you need inside a Ruby script, within which you can change the directory using a Ruby command and then execute any shell commands via the system or backtick commands, and then switch back/again the directory using Ruby. previous_dir=Dir.pwd puts "your first directory was #{previous_dir}" puts "System command pwd says we're here:" p shell_previous_dir=`pwd` Dir.chdir("/usr/local") # in Linux/Mac; use e.g., Dir.chdir("C:/") in Windows changed_dir=Dir.pwd puts "you're now in directory #{changed_dir}" puts "System command pwd says we're here:" p shell_changed_dir=`pwd` Dir.chdir(previous_dir) puts "you changed your directory again, back to #{Dir.pwd}" puts "System command pwd says we're here:" p shell_changed_again_dir=`pwd` Best regards, Axel -- GMX Kostenlose Spiele: Einfach online spielen und Spa� haben mit Pastry Passion! http://games.entertainment.gmx.net/de/entertainment/games/free/puzzle/6169196