• 検索結果がありません。

Running Programs

ドキュメント内 WPS Workbench User Guide (ページ 65-70)

This section of the guide describes the various ways you can run a program and how to cancel a run before it has completed executing.

Run a Program Inside The Workbench

There are several ways to run a program inside the Workbench.

If you have more than one WPS Server registered in the Workbench, one of the servers will be set as the default. The default server (highlighted in bold) is always shown at the top of the list of Servers in the WPS Server Explorer View. You can run programs on any server, and shortcuts offer a simple and quick way to run them on the default server.

Run from the Main Menu

To run a program inside the Workbench from the Main Menu:

1. Select the program you want to run by using one of the following methods:

• in the Project Explorer View or the File Explorer View, highlight the program you want to run.

• ensure the program you want to run is open in the editor window and has focus.

2. If the program was already open and you have part of the program highlighted, then the selected part will be executed and not the whole program.

3. Execute Run by doing one of the following:

• From the main menu, select WPS > Run > Local Server or substitute the name of your WPS Server in place of Local Server.

• Use the CTRL+R keyboard shortcut to run on the default server.

While the program is executing, at the bottom right of the Workbench you will see an indication that the run is in progress.

Note: For details about various preferences that can be specified with respect to running programs, please refer to WPS .

Remember: When you run a program it can interact with other data sets, file references, etc, that have been previously created. To clear the state of the WPS Server you can Restart Server.

Run from the Context Menu

To run a program inside the Workbench from context menus:

1. Select the program you want to run by one of the following methods:

• in the Project Explorer View or the File Explorer View, right click the program you want to run. You will then see the context menu.

• ensure the program you want to run is open in the editor window and has focus, and right click in the editor window.

2. If the program was already open and you have part of the program highlighted, then the selected part will be executed and not the whole program.

3. From the context menu, select Run > Local Server or substitute the name of your WPS Server in place of Local Server.

While the program is executing, you will see at the bottom right of the Workbench an indication that the run is in progress.

Note: For details about various preferences that can be specified with respect to running programs, please refer to WPS .

Remember: When you run a program it can interact with other data sets, file references, etc, that have been previously created. To clear the state of the WPS Server you can Restart Server.

Run part of a Program

You can select a group of lines in a program and run them:

1. Make sure the program you are interested in is open and has been given focus.

2. Highlight the section of code in the program you wish to run.

3. Execute Run by doing one of the following:

• From the main menu, select WPS > Run > Local Server or substitute the name of your WPS Server in place of Local Server.

• Use the CTRL+R keyboard shortcut to run on the default server.

• Right click in the Editor window and click Run > Local Server from the menu, or substitute the name of your WPS Server in place of Local Server.

While the program is executing, at the bottom right of the Workbench you will see an indication that the run is in progress.

Remember: When you run selected lines from a program they can interact with other data sets, file references, etc, that have been previously created. To clear the state of the Server you can Restart Server feature.

Stopping a Run

If a program is running and you want to stop it before it has finished executing:

1. From the main menu, select the WPS > Cancel > Local Server option. Substitute server name for Local Server if you are not using the default local server.

2. You can alternatively use the button in the Progress view

3. When the progress indicator in the lower right corner of the Workbench disappears, the program has stopped running. Depending on the particular step that the program is executing, it may not stop immediately.

The log will contain a message similar to ERROR: Execution was cancelled.

Run a Program on the Command Line in Windows Command Line WPS

To run a program from a command line you need to use the application called wps. The executable can be found in the bin directory where WPS was installed. Running wps on its own will not do anything, so you will need to pass it some additional instructions in the following form:

wps <options> <programFileName>

Please refer to the Command Line WPS section for more details about the <options> that can be specified. Also, the Configuration Files section has more details about configuration files containing system options that are used when you run programs.

Windows command line execution

By way of an example, if you wish to run a program called 'Program1.sas' that is in the D:\Work\WPS Programs directory. In a command window change directory to where WPS is installed and then to the bin directory. Then type:

wps "D:\Work\WPS Programs\Program1.sas"

Program Results Generated by wps

When a program is run using wps, any results that are generated are automatically captured into a file called <programFileName>.lst. For example if we ran a program called Program1.sas, in the same folder as this program we would end up with a file called Program1.lst that contained the results output.

You can open this file with any text editor of your choice.

Create a batch file to call WPS

If you wish to be able to run a program or programs using the same options each time then it is advisable to create a batch file to do this for you.

If WPS is installed at C:\Program Files\World Programming WPS 3 and your program, as above, is at d:\Work\WPS Programs then you could create a batch file called RunPrograms.bat containing :

set WPSLOC=C:\Program Files\World Programming WPS 3 set PRJLOC="D:\Work\WPS Programs"

"%WPSLOC%\bin\wps" "%PRJLOC%\Program1.sas"

One benefit of the way in which the example programs work is that they use fully qualified paths, meaning they can be executed from anywhere on your machine and will still work.

Create a Log File

When running wps, it is useful to capture the log information so you can check to see if any errors or problems were encountered.

This can be accomplished by redirecting the output of the program to a file. For example, to modify the above example to redirect the output to a file called Program1.log then change the example code to:

set WPSLOC=C:\Program Files\World Programming WPS 3 set PRJLOC="D:\Work\WPS Programs"

"%WPSLOC%\bin\wps" "%PRJLOC%\Program1.sas" > "d:\Work\WPS Logs

\Program1.log"

Once the batch file is run the file Program1.log will be in the specified directory and can be viewed with the text editor of your choice. N.B. redirecting output in this manner will mean that it will not be shown in the terminal it was executed from.

Every time you capture the log information into a file with the same name, the file will be re-created. In other words, log information is not appended to the same file; it only shows details from the latest run. If you do wish for the new log to be appended then change the redirection symbol ">" to ">>". For example:

"%WPSLOC%\bin\wps" "%PRJLOC%\Program1.sas" >> "d:\Work\WPS Logs

\Program1.log"

Tip: Since log files can be too large to look for errors by hand a simple search for error to find out if the program executed correctly.

Run a Program on the Command Line in a Non-Windows Operating System Command Line WPS

To run a program from a command line you need to use the application called wps. The executable can be found in the bin directory where WPS was installed. Running wps on its own will not do anything, so you will need to pass it some additional instructions in the following form:

wps <options> <programFileName>

Please refer to the Command Line WPS section for more details about the <options> that can be specified. Also, the Configuration Files section has more details about configuration files containing system options that are used when you run programs.

Command line execution

By way of an example, if you wish to run a program called 'Program1.sas' that is in the /home/user/

programs directory. In a command window change directory to where WPS is installed and then to the bin directory. Then type:

wps "/home/user/programs/Program1.sas"

Program Results Generated by wps

When a program is run using wps, any results that are generated are automatically captured into a file called <programFileName>.lst. For example if we ran a program called Program1.sas, in the same folder as this program we would end up with a file called Program1.lst that contained the results output.

You can open this file with any text editor of your choice.

Create a shell file to call WPS

If you wish to be able to run a program or programs using the same options each time then it is advisable to create a shell file to do this for you.

Assuming WPS is installed in the directory /tools/wps and your program is located in the /home/

user/programs then you could create a text file RunPrograms.sh containing:

export WPSLOC=/tools/wps

export PRJLOC=/home/user/programs

"$WPSLOC/bin/wps" "$PRJLOC/Program1.sas"

N.B. The file will need the correct permissions before being executable.

To make this batch file run more than one program, copy the last line and modify it to run the new program.

One benefit of the way in which the example programs work is that they use fully qualified paths, meaning they can be executed from anywhere on your machine and will still work.

Create a Log File

When running wps, it is useful to capture the log information so you can check to see if any errors or problems were encountered.

This can be accomplished by redirecting the output of the program to a file. For example, to modify the above examples to redirect the output to a file called Program1.log change the example code to:

export WPSLOC=/tools/wps

export PRJLOC=/home/user/programs

"$WPSLOC/bin/wps" "$PRJLOC/Program1.sas" > "/home/user/logs/Program1.log"

Once the batch file is run the file Program1.log will be in the specified directory and can be viewed with the text editor of your choice. N.B. redirecting output in this manner will mean that it will not be shown in the terminal it was executed from.

Every time you capture the log information into a file with the same name, the file will be re-created. In other words, log information is not appended to the same file; it only shows details from the latest run. If you do wish for the new log to be appended then change the redirection symbol ">" to ">>". For example:

"$WPSLOC/bin/wps" "$PRJLOC/Program1.sas" >> "/home/user/logs/Program1.log"

Tip: Since log files can be too large to search for errors by hand, a simple search for error to find out if the program executed correctly often helps.

ドキュメント内 WPS Workbench User Guide (ページ 65-70)

関連したドキュメント