Sep 072010
 

Filename: disktest.sh

#!/bin/bash
# This script does a very simple test for checking disk space.

space=`df -h | awk ‘{print $5}’ | grep % | grep -v Use | sort -n | tail -1 | cut -d “%” -f1 -`

case $space in
[1-6]*)
  Message=”All is quiet.”
  ;;
[7-8]*)
  Message=”Start thinking about cleaning out some stuff.  There’s a partition that is $space % full.”
  ;;
9[1-8])
  Message=”Better hurry with that new disk…  One partition is $space % full.”
  ;;
99)
  Message=”I’m drowning here!  There’s a partition at $space %!”
  ;;
*)
  Message=”I seem to be running with an nonexistent amount of disk space…”
  ;;
esac

Sep 072010
 

It’s possible to use even more complicated syntax with regular expressions:

I used this in my FTP script for safety surveillor.

case “$1? in
+(start|run) ) /usr/app/startup-script ;;
@([Ss])top ) /usr/app/stop-script ;;
esac

?(pattern1 | pattern2 | … | patternn)
zero or one occurrence of any pattern

*( pattern1 | pattern2 | … | patternn)
zero or more occurrences of any pattern

@( pattern1 | pattern2 | … | patternn)
exactly one occurrence of any pattern

+( pattern1 | pattern2 | … | patternn)
one or more occurrence of any pattern

!( pattern1 | pattern2 | … | patternn)
all strings except those that match any pattern

Jan 262010
 

SSH – Secure Shell

Creating an SSH Tunnel to my router at home.
ssh -N -L 8888:1.2.3.4:80 username@computername.domainname.com
Open up a web browser on your local pc and type in http://localhost:8888 and you will
be redirected to your home router on port 80.

If you want to tunnel X through SSH type: ssh -X username@servername.
Once you log in you can type the name of a GUI program (firefox) and it will render in a window on your local machine.
-X allows X forwarding.  -x can be used to disable X11 forwarding

Use XMing to display X on Windows Xming X Server for Windows SFXPutty-XMing.Screenshots.

Using X Forwarding on Windows HowTo.

My SSH Settings