Readers will learn how to run operational mode commands from scripts.
- Applicable to the latest EdgeOS firmware on all EdgeRouter models.
Creating and Running a Custom Script
In this example a script is run to clear all the DHCP leases.
1. Log in as the root user.
2. Create a basic script using the cat command.
cat > /config/scripts/cleardhcp
2. Add the following contents to the script (note the empty line at the bottom).
/opt/vyatta/bin/vyatta-op-cmd-wrapper clear dhcp leases
echo "$(date +'%h %e %T')" `hostname` 'dhclient: DHCP leases cleared' >> /var/log/messages
3. Use CTRL+D to exit out and save the script.
4. Modify the permissions to allow the script to execute.
chmod +x /config/scripts/cleardhcp
5. Exit back to the EdgeOS command line.
6. Run the script.