NOGDUS $1670.00 has been donated to NOGDUS!
July 20, 2017, 11:33:08 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
 
   Home   Help Search Login Register  
Pages: [1]   Go Down
  Print  
Author Topic: Linux Shell Scripts  (Read 1849 times)
0 Members and 1 Guest are viewing this topic.
Richard Marks
Administrator
Offline Offline

Respect: 3425
« on: March 07, 2009, 10:40:04 PM »

Linux Shell Scripts

DoIHave.rb
This script makes it easy to find out if something is installed and get its version info.

Code:
#!/usr/env ruby
# DoIHave.rb
# a simple script for checking if something is installed
# Developed by Richard Marks <ccpsceo@gmail.com>
# depends on having aptitude installed
@packageName = $*
@command1 = %(aptitude show #{@packageName} 2> /dev/null | awk '/State/ {print $2" "$3}')
@command2 = "aptitude show #{@packageName} 2> /dev/null | awk '/Version/ {print $2}'"
@haveIt = `#{@command1}`
if @haveIt.length then
@haveVersion = `#{@command2}`
puts "#{@packageName} is #{@haveIt}version #{@haveVersion}"
else
puts "#{@packageName} is #{@haveIt}"
end

Place it on your PATH and invoke it with the name of what you are looking for:
Code:
$ DoIHave ruby1.9
ruby1.9 is not installed
$ DoIHave git
git is installed
version 4.3.20-12

If you have any cool shell scripts, go ahead and post them!
Logged

Richard Marks
Administrator
Offline Offline

Respect: 3425
« Reply #1 on: March 07, 2009, 11:07:27 PM »

A sweet little one-liner for creating really strong random passwords.
Code:
$ echo $(tr -dc "a-zA-Z0-9-_\$\+\-\?" < /dev/urandom | head -c 24)

Change the -c 24 part to change the length of the password.
Example:

Code:
$ echo $(tr -dc "a-zA-Z0-9-_\$\+\-\?" < /dev/urandom | head -c 24)
S4JZdygvhji-HOEkFii6y60d
$ echo $(tr -dc "a-zA-Z0-9-_\$\+\-\?" < /dev/urandom | head -c 24)
Txg-?R_0gArTzJfpQscRISxZ
$ echo $(tr -dc "a-zA-Z0-9-_\$\+\-\?" < /dev/urandom | head -c 24)
T5Izaqw7gB9T1gracmRRd9Nb
Cool
Logged

Richard Marks
Administrator
Offline Offline

Respect: 3425
« Reply #2 on: March 08, 2009, 12:31:14 AM »


A nifty "little" script to get your computer to wake you up. Grin
Paste this in an open terminal window, and use CTRL+C to kill your alarm when it wakes you.
Code:
$ $(TTDELAY=8h; CURTIME=`date "+%c"`; sleep $TTDELAY; TTC=0; TTCM=10; while [ $TTC -lt $TTCM ]; do espeak -p 100 -s 120 "Wake up" ; let TTC=TTC+1; done; zenity --info --text="You wanted to wake up.\n `date "+%c"` \nYou set this timer $CURTIME.\n\n I tried to call you $TTCM times\!")

Vars to change:

TTDELAY=8h set the time for the timer to 8 hours (a good night's rest)
TTCM=10 set the number of times for the 'alarm' to sound

Logged

Tags:
Pages: [1]   Go Up
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines
.: Theme by Richard Marks :.
Valid XHTML 1.0! Valid CSS!