Run Command Tutorial

 

Table of Contents

Running Simple Commands

Hello, World!

Komodo's Run Command feature offers another way to run commands that would otherwise be run on the system command line. You will start with a simple echo command.

  1. Select Tools|Run Command to open the Run Command dialog box.
  2. View Example

  3. In the Run field, enter "echo Hello World".
  4. Click the Run button to run the command. The results are displayed on the Command Output tab.
Top

The Command Output window

Output from commands is displayed on the Command Output tab.

You can also use the Command Output window to interact with commands that you run; if the command accepts input, then you can enter it directly into the command on the Command Output tab. In addition, the Command Output tab has the following features:

  • Output written to "stderr" (standard error output) is displayed in red at the top of the Command Output tab.
  • If you want to terminate a command that is running, you can click the button in the upper right-hand corner of the tab.
  • Some of the keyboard shortcuts available in Komodo's editor can also be executed on the Command Output tab. For example, Ctrl+Shift+8 displays white space and Ctrl+Shift+7 displays line endings.

The "Toggle Raw/Parsed Output View button will be discussed in the Parsing Command Output section of this tutorial.

Top

Inserting Command Output

You can insert command output into a document using the Insert output option.

  1. In the Projects pane, double click the file play.txt. This file will be opened in the Editor pane; a tab at the top of the pane displays its name.
  2. Select Tools|Run Command.
  3. In the Run field, enter the command "dir" (on Windows) or "ls -al" (on Linux).
  4. Select the Insert output check box, then click the Run button. The contents of Komodo's current directory will be inserted into "play.txt".
Top

Filtering Parts of Your Document

The Pass selection as input option passes selected text to the command that you specify. Use this option together with the Insert output option to easily filter selected regions of your document.

  1. Open play.txt from your Run Command tutorial project if it is not already open.
  2. Select all of the "frogs" lines.
  3. Select Tools|Run Command.
  4. In the Run field, enter the command "sort" (on Windows) or "sort -n" (on Linux).
  5. Note that the Pass selection as input and Insert output options were selected automatically. If you have one or more lines selected in your document, the Run Command expects that you want to filter the selected lines.

  6. Click the Run button to sort the list of frogs.

Use the command line utility, grep, to filter lines of text. Perhaps, for example, you only like red frogs and want to remove frogs of all other colors from the list.

Note that this tutorial assumes you have the grep utility installed on both your system and your PATH. Grep is a common Linux utility that searches for text and characters in files. If you are running Windows you may not have it installed. There are a number of free versions available on the World Wide Web. Search using the keywords "grep for Windows."

  1. Open play.txt from your Run Command tutorial project if it is not already open.
  2. Select the "5 red frogs" and "6 green frogs" lines.
  3. Select Tools|Run Command.
  4. In the Run field, enter the command "grep red".
  5. Click the Run button to remove all but the red frogs.

Top Previous Next