When you type the name of a directory and press slash, you Open it. When you double click on it, you Execute it. What's the difference? Not much. Open and Execute are two related commands that, for other file managers, usually are the same. The essential difference is this:
Opening a file is more like editing it -
loading it up in order to make changes to it. | |
Executing it is more like putting it to use the way it was intended -
such as executing a program or viewing an HTML file. |
These rules are not strictly adhered to - especially if one or the other interpretation is impractical or nonsensical. For instance, 'editing' an executable binary is a bad idea, so if you Open it, that means to run it, just like Execute. And, running a .c program file as if it was a complete program is rarely the right thing to do, so that Execute will do the same as Open, that is, opening it in a text editor.
That's the intent. You can always change the behavior. So for instance Open could open a .c file in a text editor, while Execute opens it in an IDE editor. Read on.
This table compares and contrasts the two commands:
how to | Open | Execute |
---|---|---|
by Menu | Open > Open | Open > Exec |
by Keystroke | type / | type Return (Enter) |
by Mouse | [none] | double click |
effect on | ||
a directory | open window in Interrogator | open window in Interrogator |
an HTML file | open file in a text or HTML editor | display file in a browser |
a Perl script | open file in a text or programming editor | run script |
a shell script | open file in a text or programming editor | run script |
a binary program | run program | run program |
a .c source file | open file in a text or programming editor | open file in a text or programming editor |
Interrogator identifies the type of file by its suffix, that is, the part of the filename after the last period character. (No MIME types are involved.) For instance, a file named trains.java would be of type java. A file named trains.tar.gz is of type gz. A file with no periods is given the special type NoSuffix.
On MacOS X, the four-character Mac type is also used. That is, a file named blah of type PICT is treated the same as if it had a name blah.PICT.
A handler is either a runnable program, a script, or a symlink or alias to another handler. It is chosen according to the first part of its name in the openers or executioners directory, the part before the first period. The handler's name after the first period is ignored, so that you can name your Perl scripts ending with .pl or whatever. For instance, if you select a file named trains.java, and type a slash character (Open), Interrogator will look for a file in the openers directory named java or java.sh, or whatever, and it will run the handler program, passing it an argument for the full pathname to the file trains.java.
If no such handler is found, Interrogator will then also look in the executioners directory. (Similarly if you did an Execute, it will look in the openers.) If that fails, what happens depends on details.
On MacOS X, if it appears to be a Mac file (has a type and creator), it simply opens the file as the Finder would. The Mac Finder has its own database of file types and applications to handle them. Most of those settings are OK. Handlers you set in openers and executioners can override the Mac's settings in Interrogator, and they can also be more kinds of programs, including traditional Unix programs.
On all platforms, if there's still no handler found, but it's a regular file with the Executable mode bit set, it will try to run the file as a traditional Unix executable. This only happens if the command was execute, not if it was open.
When newly installed, the openers and executioners directories come populated with some default handlers. You can add or change these any way you want.
This animation shows how to set iCab, a Mac web browser, to be the handler for html files.
1) Go to ~/.tint/executioners - you can either type that in directly or as shown.
2) The handler for html files is a symlink to the default, Safari. Note that the handler for htm just points to html so that will switch over automatically.
3) Delete the html symlink. Drag a symlink from your iCab application. Unix executables, MacOS X and Classic applications can all be used this way. Rename it to html.
4) Wait for Interrogator to notice the change, or Quit and restart Interrogator if you get impatient.
Here are some keystrokes you might use.
X11 | MacOS | |
get to home directory | ~ / | ~ / |
delete a selected file | shift ^ alt T | cmd ^ T |
delete a selected file (alternate) |
Delete | Delete which one? |
drag to make a link | shift ^ alt click | option cmd click |
Rename mode | shift ^ alt R | cmd ^ R |
MacOS 9 and earlier, and MS Windows and MS DOS, do not have executable bits on their files. There simply is no such bit or any place to store such information. Therefore, when making such files visible to Unix-type systems, there was usually some feature that would assume the Execute bit was either on all the time or off all the time. (Actually it would assume it from the Read bit - any file that was readable was assumed to be executable.) Many early versions of Linux and other Unix dialects could be installed entirely using MS DOS formatted partitions (typically FAT 16 or FAT 12). These people typically set the Execute bit on all the time, otherwise the system could not run any programs at all, not even its own kernel.
This convention spread far and wide. For instance, the Unzip program typically sets the executable bit on files that are expaded in Unix that come from outside Unix. Files that are created by MacOS 9 often mindlessly have their executable bits set. The result can be directories full of JPEG files that all inappropriately have their executable bits set.
Compounding this problem, Unix executables often have no suffix. (See /bin and /usr/bin for examples.) So while you can pick out files like runp.jpeg and say that they are not programs, that's not so easy with a file named runp. On the MacOS verision of Interrogator, it looks at the Mac type information, which is usually zeros for Unix-derived files. It also looks to see if it has a period in the name for a suffix (any place other than the first character). If either is true, Interrogator overrides an executable bit, assuming that the file is actually not executable. (Files with the specific suffixes .sh, .csh, .py, .rb, and .pl are directed to their appropriate interpreters due to default executioner handlers.)
Of course if you need to enter more complicated commands, you should probably just use the command line.
The Inspector window shows a progress bar for every job in Interrogator, so when you run a program, it shows up here.
We're looking at the
/bin directory, with all of the familiar unix commands.
We run ls.
The output shows up in the inspector window.
Once the program ends, its bar changes from green to gray.
It then stays around for 1 minute, and then it's gone.
The progress when it is gray shows you how much time you have left.
(While the program is running, it's impossible to tell how 'finished'
it is, so the green progress bar doesn't actually operate.
Often, the command runs very quickly.)
By clicking on a bar, you can look at the output of each job. By clicking on the hold button, you can keep it longer. By clicking on done, you can get rid of it early.
In this example, we run the equivalent of the three commands:
% ls
% date
% mv
Because mv needs arguments, it just prints an error message,
which, coming out of stderr, also appears.
X11 | MacOS | |
get to Host window | altH altO | ^H ^O |
open Volume window for selection | altV altO | ^V ^O |
Documentation > Open & Execute |
|
||||