Block reference / General

Command

Run a command or a script on the computer in CMD, PowerShell or Terminal, and keep what it prints.

In both appsWarpX BrowserWarpX Phone

Use this block when a workflow needs something only the computer can do: run a PowerShell or Python script, restart a modem, move files with a tool you already have. It waits for the command to finish, writes what it printed to the run's log, and can hand the output to a variable. It works only in the WarpX Browser desktop app, and a command runs only after somebody on that computer has seen its text and allowed it.

The Command block's settings, filled in as in the example below.

Settings

Run in

The shell that runs the command. CMD and PowerShell are there on Windows. Terminal is your own login shell on macOS and Linux, so the command sees the same PATH as your terminal. On macOS and Linux, PowerShell works only if pwsh is installed. A shell this computer does not have is marked "not on this computer".

ExamplePowerShell
Command

What to run, exactly as you would type it in that shell. Several lines run as one script. You can put {{variables.name}} in it, but the value is pasted in as it is, with no quotes and no escaping, so a value containing &, |, ;, > or quotes changes what the command does. Use only values you control here, never text read from a web page.

Example& .\rotate-modem.ps1 -Port 2
Working folder

The folder the command starts in, so .\script.ps1 and other relative paths are found there. Empty means your home folder. The folder must exist, or the block stops with an error.

ExampleC:\Users\me\Scripts
Timeout (ms) (0 to disable)

How long the command may run, in milliseconds. When time runs out, the command and every program it started are stopped. 0 waits for as long as it takes. The default is 60000, one minute.

Example30000
Save

What the block hands on. Output (stdout) is what the command printed. Errors (stderr) is its error stream. Output and errors joins the two. Everything, as an object (exitCode, stdout, stderr) gives an object you can read as {{variables.result.exitCode}}. A final line break is removed.

ExampleOutput (stdout)
Treat a non-zero exit code or a timeout as an error

On, a command that fails or runs out of time leaves by the block's fallback output, or stops with an error naming the exit code if nothing is connected there. Off, the block always goes on, and you can check the exit code yourself with Save set to the object.

ExampleChecked
Assign to variable

Keeps what Save chose in a variable as well.

ExampleChecked
Variable namewhen Assign to variable is ticked

The variable to write to. Read it later as {{variables.newIp}}.

ExamplenewIp
Insert to table

Writes the same value into a table column.

ExampleUnchecked
Select columnwhen Insert to table is ticked

The column to write to.

Exampleip

Every block also has the shared block settings — a description, Disable block and what to do on an error. Fields that take text accept data from earlier blocks.

What it hands on

Hands on what Save chose, which the next block reads as {{prevBlockData}}. The run's log keeps the shell, the command as it ran, the working folder, the exit code, how long it took and the full output and errors, and the log line shows the exit code and the first line printed, such as Exit 0 · 10.64.12.87. A command that fails with Treat a non-zero exit code or a timeout as an error ticked leaves by the fallback output; everything else leaves by the normal one.

Example: Get a new IP from a 4G modem before each profile

  1. Start
  2. Command
  3. Delay
  4. New tab
Where Command sits in the example workflow.
  1. Save your modem script as C:\Users\me\Scripts\rotate-modem.ps1. Have it print the new IP address as its last line.
  2. In the editor, add Command right after Start. Set Run in to PowerShell.
  3. In Command, write & .\rotate-modem.ps1 -Port 2. Set Working folder to C:\Users\me\Scripts.
  4. Set Timeout (ms) (0 to disable) to 30000, leave Save on Output (stdout) and keep Treat a non-zero exit code or a timeout as an error ticked.
  5. Tick Assign to variable and name it newIp.
  6. Connect the block's fallback output to Notification with the text Modem rotation failed, so a failed rotation does not go on with the old address.
  7. From the normal output, add Delay of 5000 ms while the connection settles, then New tab to start the work.
  8. Run the workflow. The first time, a window shows the command and asks you to allow it. Open the run's log to see the exit code and what the script printed.

On WarpX Phone

  • On WarpX Phone the command still runs on this computer, not on the phone. To run a command on the phone, use the phone's ADB command block.

Good to know

  • Desktop app only. In the browser extension the block is not in the list, and a workflow that has one stops before it starts, saying so.
  • Before a run starts, every command it could reach, including those inside block groups and packages, is shown in one window with its full text: Allow and run or Don't run. The answer is remembered on that computer for that exact text in that shell, so changing one character asks again.
  • Commands you type in the editor are approved on your computer as you type them, so your own commands do not ask. A workflow you import, or install from the Appstore, asks the first time it runs. Appstore listings show every command in full, even locked listings.
  • What is approved is the command as written, with its {{...}} parts unfilled. The window marks such a command Uses variables: the value of a variable can change at every run without asking again, which is why a value from a web page must never go into a command.
  • The command has no keyboard input. A program that stops to ask a question gets an empty answer and goes on or fails, rather than waiting forever.
  • Output and errors are each kept up to 1 MB. Past that, the rest is dropped and the log says Output past 1 MB was not kept.
  • CMD runs with the UTF-8 code page, and PowerShell with UTF-8 output, -NoProfile and an execution policy of Bypass, so a .ps1 script runs without changing your policy and accented text reaches the log intact.
  • A timeout stops the whole process tree, not only the shell. If the page running the workflow closes mid-run, the commands it started are stopped too.
  • Working folder may start with ~ for your home folder, as in the file blocks. A folder that does not exist stops the block before the command runs.

See also

  • File action — Write a value to a TXT, CSV or JSON file on the computer, append to one, or delete a file.
  • Read TXT — Take lines, or pieces between a delimiter, from a TXT file into a variable, optionally deleting them from the file.
  • JavaScript code — Run your own JavaScript in the page, and pass data back to the workflow.
  • HTTP request — Sends an HTTP request to a URL and can store the response.