Script files

From HotDec

Jump to: navigation, search

Contents

Bash Scripts

Here are some script files i wrote in the lab to make life easier. I keep them in ~/bin and have added the following line to .bash_profile: PATH=$PATH:$HOME/bin. I also use "chmod 700 <file>" to make them runnable. This way i can perform several commands by typing a single word.

Bash Reference


SBC login

This lets me log into the SBC's using a command like "sbc 1"


sbc:

#!/bin/bash
ssh root@192.168.0.$((200 + $1))

Log in as virtual user

This lets me log in as nobody (the user that runs httpd and the wiki) by typing "usr nobody"


usr:

#!/bin/bash
su -c "su -s /bin/bash $1"

Recursive remove

This is a safer alternative to "rm -R <folder>".


rmall:

#!/bin/bash
#

while true; do
  echo -n "REALLY remove directory $1? (y/n) "
  read yn
  case $yn in
    y* | Y* ) echo "removing directory $1..."; break ;;
    [nN]* ) echo "aborting..."; exit 1 ;;
    q* ) echo "quitting..."; exit 1 ;;
    * ) echo "unknown response.  Asking again" ;;
  esac
done

yes | rm -Rv $1
exit 0

Eclipse

This runs eclipse with the Sun VM since it doesn't work with the GNU VM.


ec:

#\!bin/bash
eclipse -vm /usr/java/jre1.5.0_06/bin/java