The BUTTON command waits for the user to press the physical push button on the top of the Packet Squirrel. Optionally, it can use a specified timeout.

Options

Calling BUTTON with no options will delay indefinitely until the user presses the physical button.

Calling BUTTON with a timeout value, in seconds, causes it to delay until the user presses the button or the timeout expires.

By default, BUTTON controls the LED to indicate that it is waiting for input; by setting the NO_LED environment variable first, BUTTON can be told to leave the LED alone:

  NO_LED=1 BUTTON
  

Return values

When called with a timeout, the BUTTON script will return a successful return code (0) when the button is pressed, and an unsuccessful result (non-0) if the timeout expires.

To learn how to write payloads which respond to return codes, check the Advanced Bash section!

Experimenting

You can experiment using the BUTTON command live, either in the Web Shell in the web UI, or via ssh!

Using the BUTTON command in the Web Shell

Examples

  #!/bin/bash

#

NETMODE NAT

LED C SINGLE

BUTTON

LED B TRIPLE
  

A more advanced payload using conditionals to check if the button was pressed:

  #!/bin/bash

#

NETMODE NAT

LED C SINGLE

BUTTON 3 && {
    LED W SOLID
} || {
    LED R DOUBLE
}