Running CLI commands remotely using Perl - Jan 2014

MVP Expert
MVP Expert

Tutorial by rosie

This is going to be a pretty straight forward tutorial for getting the results of the previous days logins from the audit-trail command from the controller via a perl script.


This script is running on an Ubuntu machine and the controller is a 7240 running with enable bypass configured.


You will need to set the host, username and password variables so they coincide with your controller and then set the array @CmdList to the commands that you want to run. The commands I have set are "no paging" so that we can get the complete results of the next command that I have set which is "show audit-trail login | include \"$date\"" which in this case we show the audit-trail for the previous day. The $date variable using the *nix date command to get the current date and subtract one day from it then store that result into $date. It works great when going from say the 1st of one month to the 31st of the previous month without having to do any of the extra work.


This script can be adapted to run many different commands and it can be used to connect to all types of devices/servers that accept SSH connections.


Script attached:


  1. Save the attached file into a directory on your Ubuntu machine, I'll put it in  /scripts/aruba and call it
  2. Open the file in your favorite text editor
  3. Set the host, username and password variables
  4. Set the array @CmdList to have the commands you want to run on the server (separated by commas)
  5. Run the following command from the terminal: sudo perl /scripts/aruba/
  6. Profit

I hope this helps some of you who are looking to modify some of the regular tasks that are performed from the CLI. If you are looking for some ideas: I use a variation of this script to get results, copy them to a file and then I use additional grep statements to further narrow down the results and email the results daily/weekly to our audit analysts. 


Have fun, post any ideas or custom scripts you've written using this tutorial as a base and please don't forget to Kudo if this has helped.




Install Ubuntu:

Net:Smiley FrustratedSH:Expect

Version history
Revision #:
1 of 1
Last update:
‎02-26-2014 08:15 AM
Updated by:
Labels (2)
Tags (1)

I see no attached script.

I would be interested in looking at this script - if it was attached.