2

I'm working on configuring the iTerm terminal emulator for the Mac to do what I want. Apparently everything is done through what they call "bookmarks." OK, fine. I'm trying to create a bookmark that will open a tab, cd to a certain Rails project, and run the command script/server. What's supposed to happen is that this will launch the server daemon ("Mongrel") and I'll see the output scrolling by every time I look at that tab.

In the config dialog, under "command" I put script/server and under "working dir" I put the project directory.

What happens is that the tab appears for 1/10th of a second then vanishes.

Recalling a similar problem I had with the Unix screen command, I tried putting a "command" of bash -c 'script/server' but the result was identical.

Ethan
  • 57,819
  • 63
  • 187
  • 237

1 Answers1

1

You're running into that problem because your script runs and then terminates. All you need to do is put a read or something equally sophisticated to say "Press any key to complete script and close window...." at the end of the script.

update

I wrote this test script:

$ cat echoscript 
#!/bin/bash
echo "Hello world"
read text
$ 

I created a bookmark so:

name: test
command: /Users/chasrmartin/echoscript
Working directory: /Users/chasrmartin

When I open the bookmark test, I see my "Hello world", and it waits until I type return. When I type return, it goes away.

Community
  • 1
  • 1
Charlie Martin
  • 110,348
  • 25
  • 193
  • 263
  • I tried "script/server ; read text ;" and "bash -c 'script/server ; read text ;'" but got the same result. – Ethan Feb 24 '09 at 20:16
  • Thanks for the update. Tried creating a bash script to launch the Ruby process and putting read text at the end. Got error saying "Rails requires RubyGems" etc. Your solution almost worked, but there's some environment issue I guess. – Ethan Feb 25 '09 at 17:54
  • Yup, your ruby script is failing; up to now you couldn't tell because the window closed. I'm guessing you should read this: http://www.ruby-forum.com/topic/173983 – Charlie Martin Feb 25 '09 at 18:54