So, I'm working on a custom makefile script (for TinyOS, if anyone cares) that builds a file and then runs it in a simulator.

The problem is that the simulator takes it's input from standard in, and if I run the makefile from the eclipse plugin that my team and I use, I'm unable to actually enter any commands into it.

I've worked around the issue by using the line

gnome-terminal --title="MSPSim Terminal" -x mspsim build/telosb/main.elf

Now, this obviously only works if the user is a) on a GNOME system, and b) has gnome-terminal.

Since I personally find this shortcut make patch super useful, I'd like to submit it as a patch to TinyOS - but obviously I need to make it portable first.

Anyone know a way to start a new terminal window, on any variant of linux, mac OSX and cygwin, preferably in a way that the file works for all three, regardless of what you're using?


You'll probably need to use a set of conditionals based on the uname and presence of the executables for potential terminals to use. Then you'll need to adjust the arguments to match what the particular terminal accepts.

  • Hm, that seems like a nasty kludge but definitely an option. Happen to be able to point me to a list of possible terminal executables? I'm familiar with the actual shells... but not so much various terminal emulators – camperdave Mar 8 '11 at 19:08
  • Another thing I thought of: I only really have experience with GNOME systems and pure SSH ones - am I likely to run into systems where there are multiple terminal options on a single system? – camperdave Mar 8 '11 at 19:18
  • @camperdave: Here is a list of terminals that are more or less compatible with xterm. Here is Wikipedia's more comprehensive list. And don't forget screen and tmux. You can probably get by with xterm, gnome-terminal, konsole, Terminal.app, rxvt and a few others. You should look for them in the $PATH rather than trying to hard-code their location, of course. – Dennis Williamson Mar 8 '11 at 19:26
  • @Dennis Williams: Well, actually I think I CAN skip screen and tmux - If the makefile is being run in a terminal, I think the problem goes away (I'm about to test that as we speak). The issue comes up when the make is started by eclipse - in which case I need to start a GUI terminal emulator, not a multiplexer. Right? – camperdave Mar 8 '11 at 19:28
  • 2
    you could do this: xterm $options || gnome-terminal $options || rxvt $options .. but its all hacky. – akira Mar 8 '11 at 19:56

there is no such tool, at least not that i am aware of. xterm is pretty close to be everywhere, but you can not be sure to have xterm installed either.

  • So, is there any way to query the system what is the default? (I'm not sure if that's a dumb question, or what) – camperdave Mar 8 '11 at 19:03
  • @camperdave: It's not a dumb question. While you'll often (but not always) see environment variables for $EDITOR and $BROWSER, I think $TERMINAL (not to be confused with $TERM) is somewhere between rare and nonexistent. – Dennis Williamson Mar 8 '11 at 19:06
  • @Dennis Williamson: That's too bad. Looks like I'm going to have to use a massive conditional block and uname... – camperdave Mar 8 '11 at 19:17
  • @Dennis Williamson: I use $TERMINAL .. :) but you are right in that that is not really 'standard'. as said: there is no such thing as the "platform independent terminal emulator thing". – akira Mar 8 '11 at 19:55

I actually ended up splitting this out of the Makefile, and into it's own shell script, due to issues with the quoting of single quotes (needed for OSX compatibility, I think).

Since this is something I intend to re-use, I've put the script online on github If your favorite terminal emulator isn't supported, send me the man page for it, so I can determine what arguments it takes, and I'll add it in.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.