How to open several Terminal Tabs in different folders (working directories)?

Solution 1:

The following works for me on oneiric. You can use this in place of your version:

#!/bin/bash
gnome-terminal --tab  --working-directory="/var/www/" --tab --working-directory='/home/' --tab --working-directory='/home/'
exit 0

Solution 2:

Your specific error is caused by not using the --execute option properly. If you look at the excerpt from the man page below, you'll note that --execute does not have an equals sign listed as part of the syntax, as it simply executes the entire rest of the command line. An example of correct use would be:

gnome-terminal --execute play '/home/cjohnson/Still Alive.mp3'

IMPORTANT NOTE:
Using cd is a bit of a special case, anyway. cd is not like most commands—it does not launch a binary/executable of its own. It is interpreted directly by bash (or whatever shell you are using). Therefore attempting to invoke cd doesn't agree with the --execute and -x flags (which seem to want to directly spawn a child process). The same issue will occur (I've checked) with other commands which are directly processed by bash like home. Even if used properly, without the equals sign, it will still result in an error: "File or directory not found." Therefore using the --working-directory=[DIRECTORY] option is your best bet for doing what you want to do.

ANOTHER IMPORTANT NOTE:
Even if this weren't the case, you would still run into trouble. The problem lies in trying to use the --execute option when you actually intend the meaning of the --command option. In the man page documentation, it states specifically

-e, --command=STRING
Execute the argument to this option inside the terminal.

-x, --execute
Execute the remainder of the command line inside the terminal.

(emphasis mine)

In other words, it's probably not going to parse it in the way you think it should. Using --execute prevents you from passing any further options to gnome-terminal.

An excerpt from one of my own scripts where I run multiple commands in separate tabs (names changed for my privacy/security):

gnome-terminal --tab --command="ssh cjohnson@GLaDOS" --tab --command="ssh drattman@GLaDOS"

(Incidentally, trying to use the --command flag with cd or home will also result in the familiar "No such file or directory" error.)

I hope this isn't too long. I'm just trying to be thorough.