Savings GMail’s to local PC

The latest Gmail web client comes with a plethora of add-ons. One of the most useful is the “Create a document” feature, which essentially turns your email into a Google Document and lets you download it to a local directory (in several formats). You can access and enable this function from the Settings “Labs” tab.

It is enabled by hitting “g” then “w”. Simply select an email and from “More” Create a document…

Now we have the email opened as a Google Document, which we can download to a local directory (in pdf format).

Now our email is stored away as a document and it cannot be tampered with as it’s a pdf.

Lastly, it’s worth noting that the document itself is also stored on-line in your Google Docs screen, which you can keep or bin.

Bash Session Title Bar

 # determine if okay to set colors and termname then does so  # checks copied from default redhat installation /etc/bashrc   # are we an interactive shell?  if [ "$PS1" ]; then      if [ -x /usr/bin/tput ]; then        if [ "x`tput kbs`" != "x" ]; then # We can't do this with "dumb" terminal          stty erase `tput kbs`        fi      fi      case $TERM in        *xterm* | dtterm | *vt100* | *linux* | *cyg* )          [ `uname -s` = "SunOS" ] && TERM=dtterm || TERM=xterm          HOST=`hostname |sed 's/\..*$//g'`          if [ ${HOST} == "unix001" ];                  then BOX="System Test"          fi          PROMPT_COMMAND='echo -ne "\033]0;${LOGNAME}@${HOST} ${BOX} : ${PWD}\007"'          PS1='\[\e[36;1m\]\u@\[\e[32;1m\]\H:\w# \[\e[0m\]'          if echo hello|grep --color=auto l >/dev/null 2>&1; then            export GREP_OPTIONS='--color=auto' GREP_COLOR='1;32'          fi          if ls --help 2>&1 |grep color >/dev/null; then            alias ls='ls -h --color=auto'          fi          ;;        *)          PS1='\u@\h \w\$ '          ;;      esac  fi 

C++ version and dependencies

Before calling a compile C++ executable from a script, it’s worth checking you have the version you expect and that all it’s dependencies are in place.

ldd <program_name>     will list all it’s dependencies

file <program_name>     will give you the version, for example

“ELF 32-bit LSB executable 80386 Version 1 [FPU], dynamically linked, not stripped”

Disable SFTP

In a test/UAT environment you might find it prudent to disable nasties like SFTP, FTP or mailx, such that if you’ve copied your scripts and config file over from production, they don’t inadvertently send you test files out to ‘live’ users & systems.

A quick way to do this is create a /bin directory in your user’s root and put in ‘dummy’ executable versions of ftp, mail, mailx and sftp (say with a single echo statement embedded).

Now add this directory to your $PATH so that it gets called before the real commands.

(eg edit ~./profile and add PATH=.:/usr/local/etc:~/bin🙂

Double check with a “which sftp” and it should now point to your dummy version.

Control M Agent on Unix

Some useful infor on where to find stuff on your Contrl M agent (ctmag).

On any unix build go to : /opt/cntlm/ctmag3/ctm/     where agent 3 is the active agent.

sub dirs:

  • proclog: a great place to check on health of agent. Look here for issues with locked or dead users inhibiting jobs running.
  • sysout: the place where the sysouts go! better to use unix directly rather than the Contrl M Enterprise GUI, if you’re happy with find’ing and grep’ing for what you need.

(if you’re on a win server, then C:/Program Files/BMC should get you close to the equivalent of above).


Find differences in permissions

What if you have an app installed in several machines, most work fine but one doesn’t!

You’ve done a diff on the directory contents and they match, but it could be that some thoughtful person has chmod’ed one of the executables, but which one?

On each app tree run this:

ls -l  | awk ‘{ print $1″ “$9 }’ > diff_filex.txt


Then compare the 2 diff_files with sdiff. The awk returns the permissions (col 1) and the file name (col 9).

Re-delimit a large file

So what if you have an huge file that you cant simply open and do a find and replace on? But you need to change the delimiters so as to process it somewhere else.

We can use sed to accomplish this in UNIX.

sed -e ‘s+,+\*+g’ bigfile.prn > bigfile_newdelim.csv

Then simply repace the current delimiter “~” with a new one, say “,”

sed -e ‘s+~+,+g’ bigfile_newdelim.csv > bigfile.csv

Delete the *newdelim file afterwards I reckon.


If you put this file in your user profile directory (~) it will give you nice colours, make the back key work and set up user defined variables for your session. This is for a Sybase oriented app server.

create a file called .bashrc, then copy in this code


export PATH=$PATH:/usr/local/bin/:/usr/ucb/:/usr/sbin/:/usr/local/sbin/

# Set Sybase environment variables
export SYBASE=/opt/sybase/DBAsdk014
export SYBASE_OCS=OCS-15_0
export PATH=/opt/sybase/DBAsdk014/OCS-15_0/bin:$PATH
export LD_LIBRARY_PATH=/opt/sybase/DBAsdk014/OCS-15_0/lib:/opt/sybase/DBAsdk014/OCS-15_0/lib3p64:/opt/sybase/DBAsdk014/OCS-15_0/lib3p:$LD_LIBRARY_PATH
export INCLUDE=/opt/sybase/DBAsdk014/OCS-15_0/include:$INCLUDE
export LIB=/opt/sybase/DBAsdk014/OCS-15_0/lib:$LIB

# Default Apps Setup
export HOSTNAME=`hostname`

# Locale for Sybase
export LC_ALL

# Set term
#export TERM=vt100
export TERM=dtterm

# Set erase character
stty erase ^?
stty erase ^h

# Colourise term
export PS1='\[\e[36;1m\]\u@\[\e[32;1m\]\H:\w# \[\e[0m\]'</p>'</p>'</p> <p># Call set up for title bar</p> <p>source ~/.titlebar</p>'

Process files by timestamp

Sometime we need to delete or move files based on when they were created. Heres some snippets that do just that.

Find everything created in local directory in last 24 hours and copy them out


            touch -t 01162011 reference

                        create a reference file with mod date 16 Jan 2011

            find . -newer reference -exec cp {} ./my_sub_dir \;

                        copy all files older than reference to a sub directory

scp -r ./my_sub_dir kieran@linuxpc:/home/kieran/test_dir

            take all files saved to <my_sub_dir> and copies them to destination


Move everything created in last day to new directory

            find * -mtime -1 -exec mv {} my_sub_dir \;

                        this takes all files in * and moves them to directory my_sub_dir.


Delete everything older than x days

            find /opt/kieran/logs/* -type f -mtime +1 -exec rm -f {} \;


So whats the deal with the curly braces {}?

Each file that the find command finds, is placed in the {} array, so that they can then be manipulated one at a time by the exec command.


Heres some nice links with more detail: