Category: Uncategorized

Nov 06

Sorting IP addresses in Excel

Sometimes you need to manipulate lists of IP addresses in Excel but of course it sorts on strings which is not ideal for IP addresses. A quick way to sort is adding another column with the following formula and sorting on that new column.

=((VALUE(LEFT(B6, FIND(".", B6)-1)))*256^3)+((VALUE(MID(B6, FIND(".", B6)+1, FIND(".", B6, FIND(".", B6)+1)-FIND(".", B6)-1)))*256^2)+((VALUE(MID(B6, FIND(".", B6, FIND(".", B6)+1)+1, FIND(".", B6, FIND(".", B6, FIND(".", B6)+1)+1)-FIND(".", B6, FIND(".", B6)+1)-1)))*256)+(VALUE(RIGHT(B6, LEN(B6)-FIND(".", B6, FIND(".", B6, FIND(".", B6)+1)+1))))

Comments Off on Sorting IP addresses in Excel
comments

Sep 23

Watch Process Id

Sometimes you want to keep tabs on a long running process and get notified by email when it is done. This is an example of just that.

#!/bin/bash
pid=$1
me="$(basename $0)($$):"
if [ -z "$pid" ]
then
    echo "$me a PID is required as an argument" >&2
    exit 2
fi

name=$(ps -p $pid -o comm=)
if [ $? -eq 0 ]
then
    echo "$me waiting for PID $pid to finish ($name)"
    while ps -p $pid > /dev/null; do sleep 1; done;
else
    echo "$me failed to find process with PID $pid" >&2
    exit 1
fi
## I used a python mailer but mostlikely this will be mail or mailx.
python pymail.py $pid

Comments Off on Watch Process Id
comments

Sep 23

Unix text mail to Outlook missing newlines

If you like myself have spent way too much time with Outlook chomping newlines in a simple text email this little workaround worked for me.  Assuming of course you do actually have newlines in your text that you are sending you can just use sed to add two spaces to the start of each line.

echo "$notifymessage" | sed 's/^/  /g' | mailx -r $fromuser -s "Monitor on $HOSTNAME" "$mail"

Comments Off on Unix text mail to Outlook missing newlines
comments

Jul 30

Sendmail Mail Submission

I have struggled with this before and now I will make a note of it to save myself time when I encounter this again.

I have a setup on Solaris 11 where I am running a custom filter to accept mail on port 25 and then pass it on to sendmail for processing.  My filter need the sendmail daemon and I am running the sendmail daemon on port 10026. In a normal sendmail setup you are not stealing port 25 so I doubt you will have local mail submission problems.  And you might not need local mail submission with mail or mailx anyhow.  If you do need local mail submission and defaults are not working as was in my case below is my fix.

Make sure you are running the sendmail client.

# svcs -a | grep sendmail
online         Jun_30   svc:/network/smtp:sendmail
online          6:43:35 svc:/network/sendmail-client:default

Generate /etc/mail/submit.cf. In my case I copied and edited custom_submit.mc. Note I had to use "MSA".

# pwd
/etc/mail/cf/cf
# diff submit.mc custom_submit.mc
[...]
< FEATURE(`msp', `[127.0.0.1]')dnl
---
> FEATURE(`msp', `[127.0.0.1]',`MSA')dnl

# /usr/ccs/bin/m4 ../m4/cf.m4 custom_submit.mc > /etc/mail/submit.cf

Restart client

# svcadm disable svc:/network/sendmail-client:default
# svcadm enable svc:/network/sendmail-client:default

Links:
http://docs.oracle.com/cd/E19253-01/816-4555/mailrefer-106/index.html

Configuring sendmail as an MSA

Comments Off on Sendmail Mail Submission
comments