Sie sind auf Seite 1von 24

ActiveState Docs

Komodo 4.4 Documentation


Table of Contents

RUN COMMAND TUTORIAL


Run Command Tutorial Overview Run Command Tutorial Scenario

This tutorial introduces you to the Komodo Run Command feature. You will learn how to run simple and complex custom commands (such as grep, make, and perl); use these commands to process and analyze files; save commands to run with a single keystroke; and use commands to make Komodo a more powerful editor. In this tutorial you will: 1. Run simple commands using the Komodo Run Command feature. 2. Use advanced command options to control how and where a command is run. 3. Save commands in the Toolbox and assign keyboard shortcuts. 4. Using interpolation shortcuts to customize commands for reuse. 5. Prompting for input to have your commands prompt you for information before running. 6. Parse command output into a list of results by specifying a regular expression.
Opening the Tutorial Project

On the File menu, click Open|Project and select runcmd_tutorial.kpf from the \samples\runcmd_tutorials subdirectory of the Komodo installation. All files included in the tutorial project are displayed on theProjects tab in the Left Pane.
Running Simple Commands Hello, World!

The Komodo Run Command feature offers another way to run commands that would otherwise be run on the system command line. This section starts with a simple echo command. 1. Select Tools|Run Command to open the Run Command dialog box.

2.

3. In the Run field, enter echo Hello World. 4. Click Run. The results are displayed on the Command Output tab.
Command Output Tab

Output from commands is displayed on the Command Output tab.

Use the Command Output tab to interact with commands; if the command accepts input, enter it directly into the command on the Command Output tab. 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. To terminate a running command, click the button in the upper right-hand corner of the tab. Many keyboard shortcuts available in the Komodo editor can also be executed on the Command Output tab. For example, 'Ctrl'+'Shift'+'8' ('Meta'+'Shift'+'8' on Mac OS X) displays white space and 'Ctrl'+'Shift'+'7' ('Meta'+'Shift'+'7' on Mac OS X) displays line endings (if the default key binding scheme is in effect).

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

Inserting Command Output

Insert command output into a document using the Insert output option. 1. On the Projects tab, double-click the file play.txt. The file opens 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, and then click Run. The contents of Komodo's current directory are inserted into play.txt.
Filtering Parts of a Document

The Pass selection as input option passes selected text to the specified command. Use this option together with the Insert output option to filter selected regions of a document. 1. Open play.txt from the Run Command tutorial project (if it is not already open). 2. Select all six lines containing the word frog. 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 are selected automatically. If one or more lines are selected in a document, the Run Command expects to filter the selected lines. 6. Click Run to sort the list of frogs. Use the grep command line utility to filter lines of text. Use all but the red frogs from the list.
grep

to filter out

This tutorial assumes the grep utility is installed on your system and is in your system's PATH. Grep is a Linux utility that searches for text and characters in files. Windows operating system users may not have a grep installation. There are a number of free versions available on the Web. Search using the keywords grep for Windows. 1. Open play.txt from the 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 Run to remove all but the red frogs.
Using Advanced Options

Clicking the More button in the Run Command dialog box reveals a number of advanced options.

Specifying a Command's Working Directory

To set the current working directory for a command: 1. Select Tools|Run Command. Click More to display Advanced Options. 2. In the Run field, enter the command: dir (on Windows), or ls al (on Linux). 3. In the Start in field, enter C:\ (on Windows), or /home (on Linux). 4. Click Run to generate a C:\ directory listing.
Specifying Environment Variables

Specify which environment variables to set for a command. For example, use this feature for setting PERL5LIB or PYTHONPATH when running Perl or Python scripts. 1. Select Tools|Run Command.

2. In the Run field, enter the command: set. 3. Click New... to add a new environment variable. For the variable name, enter: PERL5LIB 4. Click Add Path... to choose a value for PERL5LIB (the actual value you choose does not matter for this example). Click OK. 5. Click Run to display all environment variables. Scroll through the results on the Command Output tab until the PERL5LIB setting is located.
Running GUI Apps or Running Commands in a Console

Run GUI programs outside of the Command Output tab by changing the Run in option to No Console. 1. Select Tools|Run Command. 2. In the Run field, enter the command: mozilla If the Mozilla browser is not installed on your system, choose another GUI application to run. For example, on Windows, try running either the iexplore or notepad command. 3. From the Run in drop-down list, select No Console (GUI Application). 4. Click Run to open the GUI application rather then the Command Output tab. To run commands in a new console window: 1. 2. 3. 4. Select Tools|Run Command. In the Run field, enter the command: dir From the Run in drop-down list, select New Console. Click Run to execute the command and open a new console window.

Saving and Rerunning Commands

Save frequently used commands for quick access and reuse.


Rerunning Recent Commands

Select Tools|Recent Commands to rerun recently run commands.

Saving Commands in the Toolbox

The Run Command dialog box contains an option for saving commands in the Toolbox for reuse. A command saved in the Toolbox is indicated with the icon.

1. 2. 3. 4.

Select Tools|Run Command. In the Run field, enter the command: echo Hello World Select the Add to Toolbox check box. Click Run. Notice that a command named echo Hello World is added to the Toolbox. 5. Double-click the icon next to echo Hello World to rerun the command.
Saving Commands in a Project

Commands can also be stored in a Komodo Project.

For example, the Run Command Tutorial project includes a Command to echo "Hello World". Consider adding commands to your projects to run make or other command line tools. There are two ways to add commands to a project:

Right click on a project and select Add New Command.... Drag and drop a command from the Toolbox tab or another open project onto the Projects tab.

Editing Saved Command Properties

Edit command properties in the Command Properties dialog box.

To open this dialog box, right click on any saved command and select Properties.
Using Interpolation Shortcuts

Run Command can use interpolation shortcuts for putting filenames, directory names, paths and other arguments into commands as variables. This creates commands that are more generic and useful. Enter command shortcuts in the Run and Start in fields, or select them from the dropdown lists to the right of the Run and Start in fields. Windows users should enclose all interpolation shortcuts (with the exception of %(browser)) in double quotation marks to ensure that spaces in filenames or file paths are interpreted correctly. Click the arrow button to the right of the Run field to view a list of Run Command shortcuts.

Shortcuts for the Current File

The string

%F

in a command expands the full path of the current file.

1. On the Projects tab, double-click the file play.txt. The file opens 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:
echo "%F"

4. Click Run. Change the current file status from "writable" to "read-only". 1. Open play.txt (if it is not already open). 2. Select Tools|Run Command. 3. In the Run field, enter the command:
attrib +R "%F"

on Windows, or:
chmod u+w "%F"

on Linux. 4. Click Run. The result is displayed at the top of the Command Output tab. To open a current HTML file in a Web browser, combine %F with the %(browser) shortcut. 1. On the Projects tab, double-click the file index.html. 2. Select Tools|Run Command.

3. Click the arrow to the right the Run field to display the shortcuts drop-down list. Select %browser, press the space bar, and then select %F. Enclose the %F in double quotation marks. On Mac OS X, you wil have to add 'open' at the beginning of the command if Safari is your default browser. 4. From the Run in drop-down menu, select No Console (GUI Application). 5. Click Run.
Shortcuts for the Current Selection

The %s, %S, %w and %W codes insert current selections, or the current word under the cursor, into commands. This shortcut helps when running utilities like grep, or for searching the Web. 1. 2. 3. 4. On the Projects tab, double-click the file index.html. Position the cursor over the word "PHP" in index.html. Select Tools|Run Command. In the Run field, enter the command: %(browser) http://www.google.com/search?q="%W". 5. Select the Add to Toolbox check box to save this command. 6. Click Run to search for "PHP" with Google. Now that you have searched for a word or selection in Google, try the following shortcut to search for PHP methods. 1. 2. 3. 4. Open index.html. Select the text mysql_info methods in the file. Select Tools|Run Command. In the Run field, enter the command "%(browser) http://www.php.net/manual-lookup.php?pattern=%S". 5. Select the Add to Toolbox check box to save this command. 6. Click Run to search mysql_info methods in PHP's online manual. These two commands are built into Komodo. If the default key binding scheme is in effect, 'Ctrl'+'F1' ('Meta'+'Ctrl'+'/' on Mac OS X) starts a Google search for the current selection. 'Shift'+'F1' ('Meta'+'/' on OS X) in a Perl, Python or PHP file starts a help search appropriate for that language. Customize searches in the Preferences dialog box (Edit|Preferences|Language Help).
Using Shortcuts for a Command's Directory

Run commands from the directory where the current file is stored, rather then the current directory. For example, use the command %(perl) "%F" to run the current file with a configured Perl interpreter. 1. On the Projects tab, double-click the file hello.pl.

2. Select Tools|Run Command. 3. In the Run field, enter the command:


%(perl) "%F"

4. In the Start in field, enter: 5. Click Run.

"%D"

This example assumes a perl interpreter is configured on your system. If a perl interpreter is not configured (the required file is perl.exe), an error message displays at the top of the Command Output tab. Alternatively, run the command dir (Windows) or ls (Linux) to display a list of files and folders beneath the current directory.
Prompting for Input Introduction

Run Commands can prompt for specific input with a dialog box. These queries can be configured with default values and/or prompt the user if no value could be determined automatically (e.g. a command to search Google for the current selection that prompts for a search term if nothing is selected). The %(ask) and %(askpass) shortcuts always prompts the user for data. Other shortcuts can use the orask modifier to prompt the user if no valid value could be determined. Windows users should enclose all Komodo shortcuts (with the exception of %(browser)) in double quotation marks. This is necessary to ensure that any spaces in filenames or file paths are interpreted correctly.
Always Prompting with %(ask) or %(askpass)

The full syntax of

%(ask)

and

%(askpass)

shortcut are:

%(ask[:NAME:[DEFAULT]]) %(askpass[:NAME:[DEFAULT]])

where NAME is an optional name to use when prompting in the dialog box and DEFAULT is an optional default value to place in the dialog box. For example: 1. Select Tools|Run Command. 2. In the Run field, enter the command:
"%(ask)"

echo Your favorite number is

3. Click the Run button to run the command. The Interpolation Query dialog box is displayed.

4. Enter your favorite number and click OK to finish running the command. Refine this shortcut by adding a more meaningful name than "Value 0" and a more appropriate default value. 1. Select Tools|Run Command. 2. In the Run field, enter the command:
"%(ask:Fav Number:42)"

echo Your favorite number is

3. Click the Run button to run the command. The Interpolation Query dialog box will now look like this:

4. If your favorite number does not happen to be 42, enter a different number and click OK to finish running the command.
Prompting When Necessary with %(...:orask)

Any Run Command shortcut can be modified to prompt the user for a value if one cannot be determined automatically. The full syntax of the modified shortcut is:
%(SHORTCUT:orask[:NAME])

where

NAME

is an optional name to use when prompting in the dialog box.

In the previous step we created a shortcut to search for the selected word on Google with the command:
%(browser) http://www.google.com/search?q="%W"

However, if nothing has been selected and there is no word under the cursor, the command fails. In this case, it would be better if the command prompted you for a search term.

1. Be sure your cursor is not positioned over a word. 2. Select Tools|Run Command. 3. In the Run field, enter the command:
%(browser) http://www.google.com/search?q="%(W:orask:Search for)"

4. Click Run. The Interpolation Query dialog box prompts for a search term.
Parsing Command Output Introduction

Use Run Commands to specify a regular expression to parse filename and line number information from lines of output. The parsed results are displayed in a table to quickly identify the desired file. Explore this usage by creating a "Find in Files" command later in this section.
Parsing Output with a Regular Expression

Output from a run command can be parsed with a Python regular expression and displayed in the Command Output tab as a list. Komodo Tip: Use the Komodo Rx Toolkit to build, edit, or test regular expressions. New to regular expressions? The Regular Expressions Primer is a tutorial for those wanting to learn more about regex syntax. Named groups in Python regular expressions (e.g. (?P<name>pattern) ) can be used to sort match data. The names 'file', 'line', 'column' and 'content' can be used as column titles in Parsed Ouptut mode, with the matching text displayed in the columns under the names. For example, the output of the "Find in Files" example below contains the following:
hello.pl:5:print "Hello, frogs!\n";

Output lines are of the form:


<file>:<line>:<content>

An regular expression to match the important elements of this line could be:
(.+?):(\d+):(.*)

However, to view this information as a useful list, we need to define the column headings by naming the groups:
(?P<file>.+?):(?P<line>\d+):(?P<content>.*)

When parsing the run command output, Komodo determines that hello.pl is the file, 5 is the line and print "Hello, frogs!\n"; is the content, and displays the output sorted into the appropriate columns:

Parts of the output that match outside the named groups in the regular expression (e.g. the ":" delimiters seen above) are visible when viewed as raw output, but are hidden when viewed as a list. You can use this technique to filter out extraneous information when viewing output as a list. For example, if you were not interested in viewing the line number of the match, you could change the regular expression to the following:
(?P<file>.+?):\d+:(?P<content>.*)

Komodo can use the information from the 'file' and 'line' groups to open a file in an editor tab at a particular line (see below).
Using "Find in Files"

Create a "Find in Files" command using all information presented in this tutorial. 1. 2. 3. 4. On the Projects tab, double-click the file hello.pl. Position the cursor over the word frogs. Select Tools|Run Command. On Windows, enter the command:
findstr /s /n /c:"%(w:orask:Search Term)" "%(ask:File Pattern:*.*)"

Or on Linux enter the command:

find . -name "%(ask:File Pattern:*)" | xargs -l grep -nH "%(w:orask:Search Term)"

Note that findstr is a Windows command line utility that searches for strings in files. 5. Select the Add to Toolbox check box to save this command. 6. In the Start in field, enter:
%(ask:Start Directory:%D)

(When the command is run, Komodo should prompt for the "Start Directory" using the directory of the current file, or %D as the default value). 7. Select the Parse output with check box and enter:
^(?P<file>.+?):(?P<line>\d+):(?P<content>.*)$

as the regular expression with which to parse. 8. Select the Show parsed output as a list check box. 9. Click Run. The Interpolation Query dialog box is displayed.

10. Click OK to run findstr. A list of all occurrences of "frogs" in the files of the Run Command tutorial project is displayed on the Command Output tab.

11. Double-click on a parsed result to jump to a specific file and line. 12. Click the button to toggle back to the Command Output tab.

13. Alternatively, double-click on lines in the raw output view to jump to that file and line.
2012 ActiveState Software Inc. All rights reserved. ActiveState, Komodo, ActivePerl, ActivePython, ActiveTcl, and Stackato are registered trademarks of ActiveState. All other marks are property of their respective owners.

Looking for documentation for the current Komodo IDE release? [x]

To Access Accessibility Controls Accessibility Wizard Add Hardware Wizard Add/Remove Programs Administrative Tools Adobe Acrobat (if installed) Adobe Designer (if installed) Adobe Distiller (if installed) Adobe ImageReady (if installed) Adobe Photoshop (if installed) Automatic Updates Bluetooth Transfer Wizard Calculator Certificate Manager Character Map Check Disk Utility Clipboard Viewer Command Prompt Component Services

Run Command access.cpl accwiz hdwwiz.cpl appwiz.cpl control admintools acrobat formdesigner acrodist imageready photoshop wuaucpl.cpl fsquirt calc certmgr.msc charmap chkdsk clipbrd cmd dcomcnfg

Computer Management Control Panel Date and Time Properties DDE Shares Device Manager Direct X Control Panel (if installed)* Direct X Troubleshooter Disk Cleanup Utility Disk Defragment Disk Management Disk Partition Manager Display Properties Display Properties Display Properties (w/Appearance Tab Preselected) Dr. Watson System Troubleshooting Utility Driver Verifier Utility Event Viewer Files and Settings Transfer Tool File Signature Verification Tool Findfast Firefox (if installed) Folders Properties Fonts Fonts Folder Free Cell Card Game Game Controllers Group Policy Editor (XP Prof) Hearts Card Game Help and Support HyperTerminal Iexpress Wizard Indexing Service Internet Connection Wizard Internet Explorer Internet Properties

compmgmt.msc control timedate.cpl ddeshare devmgmt.msc directx.cpl dxdiag cleanmgr dfrg.msc diskmgmt.msc diskpart control desktop desk.cpl control color drwtsn32 verifier eventvwr.msc migwiz sigverif findfast.cpl firefox folders control fonts fonts freecell joy.cpl gpedit.msc mshearts helpctr hypertrm iexpress ciadv.msc icwconn1 iexplore inetcpl.cpl

Internet Setup Wizard IP Configuration (Display Connection Configuration) IP Configuration (Display DNS Cache Contents) IP Configuration (Delete DNS Cache Contents) IP Configuration (Release All Connections) IP Configuration (Renew All Connections) IP Configuration (Refreshes DHCP & Re-Registers DNS) IP Configuration (Display DHCP Class ID) IP Configuration (Modifies DHCP Class ID) Java Control Panel (if installed) Java Control Panel (if installed) Keyboard Properties Local Security Settings Local Users and Groups Logs You Out Of Windows Malicious Software Removal Tool Microsoft Access (if installed) Microsoft Chat Microsoft Excel (if installed) Microsoft Frontpage (if installed) Microsoft Movie Maker Microsoft Paint Microsoft Powerpoint (if installed) Microsoft Word (if installed) Microsoft Syncronization Tool Minesweeper Game Mouse Properties Mouse Properties Nero (if installed) Netmeeting Network Connections Network Connections Network Setup Wizard Notepad Nview Desktop Manager (if installed)

inetwiz ipconfig /all ipconfig /displaydns ipconfig /flushdns ipconfig /release ipconfig /renew ipconfig /registerdns ipconfig /showclassid ipconfig /setclassid jpicpl32.cpl javaws control keyboard secpol.msc lusrmgr.msc logoff mrt msaccess winchat excel frontpg moviemk mspaint powerpnt winword mobsync winmine control mouse main.cpl nero conf control netconnections ncpa.cpl netsetup.cpl notepad nvtuicpl.cpl

Object Packager ODBC Data Source Administrator On Screen Keyboard Opens AC3 Filter (if installed) Outlook Express Paint Password Properties Performance Monitor Performance Monitor Phone and Modem Options Phone Dialer Pinball Game Power Configuration Printers and Faxes Printers Folder Private Character Editor Quicktime (If Installed) Quicktime Player (if installed) Real Player (if installed) Regional Settings Registry Editor Registry Editor Remote Access Phonebook Remote Desktop Removable Storage Removable Storage Operator Requests Resultant Set of Policy (XP Prof) Scanners and Cameras Scheduled Tasks Security Center Services Shared Folders Shuts Down Windows Sounds and Audio Spider Solitare Card Game

packager odbccp32.cpl osk ac3filter.cpl msimn pbrush password.cpl perfmon.msc perfmon telephon.cpl dialer pinball powercfg.cpl control printers printers eudcedit QuickTime.cpl quicktimeplayer realplay intl.cpl regedit regedit32 rasphone mstsc ntmsmgr.msc ntmsoprq.msc rsop.msc sticpl.cpl control schedtasks wscui.cpl services.msc fsmgmt.msc shutdown mmsys.cpl spider

SQL Client Configuration System Configuration Editor System Configuration Utility System File Checker Utility (Scan Immediately) System File Checker Utility (Scan Once At The Next Boot) System File Checker Utility (Scan On Every Boot)

cliconfg sysedit msconfig sfc /scannow sfc /scanonce sfc /scanboot

System File Checker Utility (Return Scan Setting To Default) sfc /revert System File Checker Utility (Purge File Cache) System File Checker Utility (Sets Cache Size to size x) System Information System Properties Task Manager TCP Tester Telnet Client Tweak UI (if installed) User Account Management Utility Manager Windows Address Book Windows Address Book Import Utility Windows Backup Utility (if installed) Windows Explorer Windows Firewall Windows Magnifier Windows Management Infrastructure Windows Media Player Windows Messenger Windows Picture Import Wizard (need camera connected) Windows System Security Tool Windows Update Launches Windows Version (to show which version of windows) Windows XP Tour Wizard Wordpad sfc /purgecache sfc /cachesize=x msinfo32 sysdm.cpl taskmgr tcptest telnet tweakui nusrmgr.cpl utilman wab wabmig ntbackup explorer firewall.cpl magnify wmimgmt.msc wmplayer msmsgs wiaacmgr syskey wupdmgr winver tourstart write

Search

Free Interview Questions


Just another WordPress site
Home Request Form
Web Browser Common Browser Shortcuts (Chrome, Firefox, IE) Complete List of stsadm Commands in SharePoint
AUG

18

List Of Run Commands(PDF) For Windows XP , Vista, 7


Shortcuts by Prabhu

Here is some of the keyboard shortcuts I have come across and have found them to be very useful. To Download this PDF : List Of Run Commands For Windows

To Access Add/Remove Programs Administrative Tools Adobe Acrobat (if installed) Adobe Photoshop (if installed) Bluetooth Transfer Wizard Calculator Clipboard Viewer Command Prompt Computer Management Control Panel

Run Command appwiz.cpl control admintools acrobat photoshop fsquirt calc clipbrd cmd compmgmt.msc control

Date and Time Properties Device Manager Direct X Troubleshooter Disk Cleanup Utility Disk Defragment Disk Management Disk Partition Manager Display Properties Display Properties Event Viewer Firefox (if installed) Folders Properties Fonts Fonts Folder Free Cell Card Game Game Controllers Hearts Card Game Help and Support Internet Explorer IP Configuration (Display Connection Configuration) Java Control Panel (if installed) Java Control Panel (if installed) Keyboard Properties Logs You Out Of Windows

timedate.cpl devmgmt.msc dxdiag cleanmgr dfrg.msc diskmgmt.msc diskpart control desktop desk.cpl eventvwr.msc firefox folders control fonts fonts freecell joy.cpl mshearts helpctr iexplore ipconfig /all jpicpl32.cpl javaws control keyboard logoff

Malicious Software Removal Tool Microsoft Access (if installed) Microsoft Excel (if installed) Microsoft Frontpage (if installed) Microsoft Movie Maker Microsoft Paint Microsoft Powerpoint (if installed) Microsoft Word (if installed) Nero (if installed) Notepad Outlook Express Paint Performance Monitor Performance Monitor Phone and Modem Options Pinball Game Power Configuration Printers and Faxes Printers Folder Quicktime (If Installed) Quicktime Player (if installed) Real Player (if installed) Regional Settings Registry Editor

mrt msaccess excel frontpg moviemk mspaint powerpnt winword nero notepad msimn pbrush perfmon.msc perfmon telephon.cpl pinball powercfg.cpl control printers printers QuickTime.cpl quicktimeplayer realplay intl.cpl regedit

Registry Editor Remote Desktop Removable Storage Removable Storage Operator Requests Scanners and Cameras Scheduled Tasks Security Center Services Shared Folders Shuts Down Windows Sounds and Audio Spider Solitare Card Game System Configuration Editor System Configuration Utility System Information System Properties Task Manager Windows Backup Utility (if installed) Windows Explorer Windows Firewall Windows Media Player

regedit32 mstsc ntmsmgr.msc ntmsoprq.msc sticpl.cpl control schedtasks wscui.cpl services.msc fsmgmt.msc shutdown mmsys.cpl spider sysedit msconfig msinfo32 sysdm.cpl taskmgr ntbackup explorer firewall.cpl wmplayer

Windows Version (to show which version of windows) winver Wordpad write

Das könnte Ihnen auch gefallen