Home > bash scripting, Solaris > Clear Digi_PortServer_TS16’s buffer using Scheduler on Solaris 10

Clear Digi_PortServer_TS16’s buffer using Scheduler on Solaris 10


Description : Digi PortServer TS16 always hang after operating for hours, and need to hot-restarted.
Analysis of Problem : We assume device hang because of buffer over flow.
Solution : Create script with specific function (login to the device, clear all buffer, logout) and execute automagicaly with cron scheduler.

Figure 1. Digi PortServer TS16 connect to Solaris box via UTP Cable


The Shell Script written based on expect program that has some dependencies before used, download and install dependencies first before create & execute the script.

Handling Dependencies
  1. Download packages
  2. expect
    libgcc or gcc
    xft [optional]
    render [optional]
    xrender [optional]
    expat [optional]
    fontconfig [optional]
    freetype [optional]
    zlib [optional]

  3. Extract packages one by one
  4. gunzip package_name.gz

    or extract all *.gz within directory

    gunzip *.gz

  5. Install Packages One by One
  6. pkgadd -d package_name

Create Shell Script
  1. (use your favorite text editor)Create the script named digi_clear_buffer.sh
  2. #!/usr/local/bin/expect -f
    log_user 0
    set ADDRESS [lindex $argv 0]
    set USERNAME [lindex $argv 1]
    set PASSWORD [lindex $argv 2]
    set PROMPT "#> "
    set COMMAND "set buffer clear range=1-16"
    spawn telnet ${ADDRESS}
    expect "login:"
    send -- "${USERNAME}\r"
    expect "Password:"
    send -- "${PASSWORD}\r"
    expect "${PROMPT}"
    send -- "#!/usr/bin/bash\r"
    expect "${PROMPT}"
    send -- "${COMMAND}\r"
    expect "${PROMPT}"
    send -- "exit\r"

  3. Make script executable
  4. chmod +x digi_clear_buffer.sh

  5. Try to execute manually
  6. ./digi_clear_buffer.sh remote-ip-address remote-username remote-password

    example :

    ./digi_clear_buffer.sh admin password

Execute Automagically using Cron Scheduler
  1. Edit crontab
  2. If you are not familiar with crontab format, please RTFM first

    crontab -e

  3. Try run digi_clear_buffer.sh every minute
  4. * * * * * /full/path/to/script/digi_clear_buffer.sh admin password

  5. Watch the cron’s log file and make sure your script execute flawlessly (without error)
  6. tail -f /var/cron/log

  7. Re-edit crontab, and change the time setting
  8. (I setup crontab to run the script every 6 hours)

    0 */6 * * * /full/path/to/script/digi_clear_buffer.sh admin password

Special Thanks

  1. Mr. Salik : Trouble finder & shooter.
  2. Mr. Fredy S : Idea.
  3. Me (LQman) : shell script lover 😀


  1. http://oreilly.com/catalog/expect/chapter/ch03.html
  2. http://www.tcl.tk/man/expect5.31/expect.1.html
  3. http://www.freebsd.org/cgi/man.cgi?query=crontab&sektion=5
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: