Sheerpower Logo

Interacting with the Operating System Using PASS


Introduction

SheerPower's pass statement lets you run external shell commands from within your program. This is useful for interacting with the operating system, calling utilities, or generating files for use in clusters.

Basic Usage

The pass statement takes a string expression as its argument. This string is passed to the operating system as a shell command.

pass "dir > listing.txt"

This example writes a directory listing to a file named listing.txt.

Optional NOWAIT Feature

The pass statement also supports an optional modifier: nowait.

NOWAIT: Runs the command in the background without waiting. Useful for launching external tools without blocking execution.

pass nowait: "calc"

This launches the Windows calculator and immediately resumes program execution.

Real-World Example: Exporting Chrome Processes to CSV

This example uses the Windows tasklist utility to find all running Chrome processes, saves the output to a CSV file for analysis, and loads it into a SheerPower cluster for further processing.

cluster tasks: Image$, pid$, session_name$, session_nbr, memk$ output_file$ = filespec$("@chrome.csv") cmd$ = 'tasklist /fi "imagename eq chrome.exe" /fo csv > ' + output_file$ pass cmd$ cluster input name output_file$, headers 1: tasks print 'Here are the CHROME processes' print cluster tasks: all
Note: The @ in filespec$("@chrome.csv") refers to the path of the currently running program. The output file will be placed in the same directory as the .sprun or .spsrc file.
Summary: The pass statement lets you easily run shell commands from within a SheerPower application. It connects your program to OS data, like system processes, and enables using system command line tools.
Hide Description

    

       


      

Enter or modify the code below, and then click on RUN

Looking for the full power of Sheerpower?
Check out the Sheerpower website. Free to download. Free to use.