filesize bash scripts

August 25th, 2009
immediate_filesize()
{ cat "`dirname $1`/.(use)(2)(`basename $1`)'" |
grep l= | sed -e's/.*;l=([0-9]*).*/1/'; }
filesize()
{ for try in 1 2 3; do S=`immediate_filesize $1`;
if [ -n "$S" ]; then echo $S; break; else sleep 30; fi; done ; }

tell terminal.app

August 17th, 2009
tell application "Terminal"
        activate
        with timeout of 1800 seconds
                do script with command "top"
                tell window 1
                        set background color to "black"
                        set cursor color to "green"
                        set normal text color to "yellow"
                        set bold text color to "red"
                        set title displays shell path to true
                        set title displays window size to true
                        set title displays device name to true
                        set title displays file name to true
                        set title displays custom title to true
                        set custom title to "bozo"
                        set number of columns to 80
                        set number of rows to 40
                end tell
        end timeout
end tell

remove first 4 letters in each line

August 6th, 2009
sed 's/^.{4}//g' file
sed -s 's/^[[:alpha:]]{4}//g' file
sed -s 's/^[a-zA-Z]{4}//g' file

change channel status in fts

August 6th, 2009
for i in `glite-transfer-channel-list` ; do glite-transfer-channel-set -S Drain $i ; done ;
for i in `glite-transfer-channel-list` ; do glite-transfer-channel-set -S Active $i ; done ;

MINI Cooper navigation diagnostics

June 25th, 2009
You can see many different version numbers and other diagnostics on a hidden OSD screen (no idea if this works on cars past the 07 model year).

  1. Go to home screen
  2. Hold joystick down for 15 seconds
  3. Turn 3 clicks right
  4. Turn 3 clicks left
  5. Turn 1 click right
  6. Turn 1 click left
  7. Turn 1 click right
  8. Press joystick once

lcg-infosites and lcg-info

June 9th, 2009
lcg-infosites --vo cms se --is lcg-bdii.cern.ch
lcg-info --list-se --vo cms  --attrs 'AvailableSpace'

find Mac display part number

June 1st, 2009
ioreg -lw0 | grep IODisplayEDID | sed "/[^<]*</s///" | xxd -p -r | strings -6

sum dataset

May 20th, 2009
dbs search --noheader --query="find sum(block.size), dataset where site = T1_SOMESITE”

sum add columns in a text file

May 20th, 2009
awk 'BEGIN {x=0} {x+=$1} END {print x}' /tmp/z1
awk -F" " 'BEGIN {x=0} {x+=$2} END {print x}' cols

procedure to copy files to CERN CASTOR

May 19th, 2009
1. make a directory in the castor area and give it the right permissions (gets the correct mapping):

nsmkdir /castor/cern.ch/user/u/user/a
nschmod 775 /castor/cern.ch/user/u/user/a

2. Use lcg-cp or srmcp:

lcg-cp -v --vo cms
file:////data/user/job/LM1_SUSY_Tree.root
srm://srm-cms.cern.ch:8443/castor/cern.ch/user/u/user/a/LM1_SUSY_Tree.root

or

srmcp -srm_protocol_version=2 -use_urlcopy_script=true -urlcopy=${SRM_PATH}/sbin/url-copy.sh
file:////data/user/job/LM1_SUSY_Tree.root
srm://srm-cms.cern.ch:8443/castor/cern.ch/user/u/user/a/LM1_SUSY_Tree.root