BUTTON
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
!

Examples
#!/bin/bash
# Title: Basic demo one
#
# Description: A simple payload that waits for a button to be pressed
# Set the netmode to NAT, otherwise there is no connectivity at all
NETMODE NAT
# Set the LED to blinking cyan
LED C SINGLE
# Wait forever until the button is tapped
BUTTON
# Set the LED to blink blue in a triple pattern
LED B TRIPLE
A more advanced payload using conditionals to check if the button was pressed:
#!/bin/bash
# Title: More advanced buttons
#
# Description: React differently if the button was pressed or not
# Set the netmode to NAT, otherwise there is no connectivity at all
NETMODE NAT
# Set the LED to blinking cyan
LED C SINGLE
# Wait 3 seconds, set the LED depending on if the user presses the button
BUTTON 3 && {
LED W SOLID
} || {
LED R DOUBLE
}
Last updated
Was this helpful?