Sunday, 27 September 2015 03:22

Send Email using the linux command line from your network devices

Written by 
Rate this item
(0 votes)

Send email via the linux command line from your devices with this gateway project

I have a few devices on my home network that I wanted to add the ability to send emails without any hassle.

The best way I found was to set up a center point device to act as a gateway, a device that is always accessible and powered on.

Using the custom sendmail wrapper script I wrote below, using a free service like gmail to do the heavy lifting, and my home router acting as the gateway, I can now easily have my linux devices send me emails without the need to have sendmail or similar tools installed on every device.

 

Why would you want to go and do a thing like that...

Sending the current WAN IP address of my router after a reboot, having a raspberry pi email me feedback from various sensors, simple scripts that provide insight on the state of my computers and network. There are many scenarios I can anticipate this being useful for, and instead of setting up each individual device with the proper programs, settings and configurations, not to mention the mis-configurations and troubleshooting as well, I wanted to create a simple gateway, which each device can go through using ssh or using a simple tcp socket connection into the gateway itself with a remote command for a simple email.

The router choice is inherently important as it requires to run some sort of *nix.  I made the decision to use my router for this project for several reasons, it has a stable linux firmware upgrade I can run, so I can easily implement the software and tools I needed to accomplish my goals for this project.  Another reason is that my router rocks!  If your router does not run a form of linux such as Asus-Merlin, DD-WRT, Open-WRT, etc. you can still create an email gateway on another device, possibly a raspberry pi, a virtual machine, or similar.  My router is an Asus RT-N66U, and I highly recommend this router for anyone that may be in the market for a new purchase.  Combined with the custom firmware available (Asuswrt-Merlin) it's a very easy to configure and flexible device.  The need to reboot the device every week (like on my old Linksys running DD-WRT) and the fact that the user interface is very intuitive even for more complex setups like outbound VPN or setting up alternative guest networks.  Whatever device you choose, this guide should help you in setting up the email gateway onto your home network.

 

On to the good stuff

To create the email gateway we need to do a few things in preparation and follow these steps to ensure everything will work as intended.  I'll go through step by step instructions that I used for my router.  If you are using another device other than an asuswrt router, setup will be similar but you may need to tweak a few items.

  • Create a Gmail account (no need to use our personal account, let's set one up specifically for our devices)
  • Setup the Gmail account for it to communicate with our gateway
  • Configure the email service to talk to gmail
  • Create a custom script to email the public IP of the router interface any time the router reboots
  • Test and setup an external device to send an email
  • Create a custom wrapper script on the router to send custom emails from any device easily

 

Create and setup the Gmail Account

You can easily use your own ISP's smtp host if allowed, but you'll need to know the ports they use, if they allow without authentication, etc.  Although with gmail, it requires the use of downloading a trusted certificate, that's not necessarly a bad thing, and we can use the same setup consistently, instead of figuring out what each ISP allows.

Create a new Gmail account.  You'll have to allow access to less secure apps, in your profile in order for this to work, which is a little tricky to find.

When you log into your gmail account, Goto Settings > Accounts and Import  then find Other Google Account settings

Command line Email Gateway 02

 

Then goto Personal info & privacy > Account overview

 Command line Email Gateway 04

 

 

Then, on the following page goto Sign-in & security > Connect apps & sites, select to turn on Allow less secure apps from OFF to ON

Command line Email Gateway 03

 

JFFS or USB flash drive

If you go with another type of device such as virtual machine or raspberry pi, you don't need to worry about storage of your files.  You can easily add them to the hard drive or sd card you are using.  With a router you have to choose JFFS (if available), USB thumb drive and even some SD mods out there.  JFFS is a writeable partition that can be created on certain flash devices.  There is good and bad to this.  Once you set your device to include a JFFS partition, you're done.  Anything in the JFFS partition will survive hard power reboots, so no need to worry about losing all of your custom configuration files and scripts during the next storm.  The partition size various from device to device, but typically its more than large enough to hold various files, and scripts.

Some routers may not have a JFFS option so you may need a USB drive in order to store any custom scripts.  Our router we are using Asus RT-N66U with the custom firmware does provide a JFFS directory so we will not be using an external storage device for this project.  In a future project we will be adding the capabilities to install entware onto a USB drive, but for now, we'll stickuse the JFFS directory.

 

Format and partition the USB thumb drive

We will use JFFS, so there's no need for the USB drive, but if you do require a USB drive to store local scripts, create a localized backup, or for future projects involving entware, which will add the ability to easily download more software onto the router, we can setup a USB drive that can live on the back of the router.

Format and Partition a USB flash thumb drive to use with Asuswrt routers is a guide I wrote specifically for that in mind.  When using a USB drive in this project, you must be sure to format the drive using the Ext2 file system, (any standard USB drive will work, but we must follow the guide to partition and format it correctly).  I use a standard 8GB USB 2.0 drive in the example shown.  The 2 separate partitions are not needed for this particular project, but if you plan on experimenting or adding additional functionality to the router, I suggest start with the 2 partitions per the guide.

 

Setup the router to enable JFFS

I had originally decided to mount the USB drive in attempt to use it as the jffs directory, in hopes a firmware upgrade wouldn't wipe out the directory with my custom files.  In doing some research I came across some forum posts from mr. merlin, the guy who actually creates this Asuswrt firmware, and he stated although you can mount a USB drive to /jffs, it would be somewhat useless as the mount of this would happen too late in the game to make use of any start-up scripts you may want to include in the jffs directory.  So, we'll use JFFS.

Enable JFFS from the web interface of the router, Adminstration > System check all three options and reboot the router, this will create a writeable /jffs/ directory along with /jffs/configs and /jffs/scripts directories on the router.  As long as you do not select option 2 again on the web interface, these directories are safe during standard reboots, but may (and it has happened to me) get wiped during a firmware upgrade.

Command line Email Gateway 01

Now we have a location to store any custom files or scripts we'll need to setup our email system on the router.

 

Setup sendmail to talk to gmail

We are using the software package known as sendmail.  A version of sendmail is already installed with the Asuswrt firmware.  If you are using another device, you may have to install sendmail, and although the first example below should send an email, the IP information and Uptime, will not show if run on another device as it's getting these variables automatically from the router.  Gmail requires the connection to be encrypted, in order to facilitate that we need to download a certificate to pass along to gmail in order for this to happen.

 

Download a trusted certificate

curl -o /jffs/configs/Equifax_Secure_Certificate_Authority.pem https://www.geotrust.com/resources/root_certificates/certificates/Equifax_Secure_Certificate_Authority.pem

 wget doesn't work with tls on the version of asuswrt firmware I am using, but curl works fine.

 

I used a sample script I found at the merlin github wiki https://github.com/RMerl/asuswrt-merlin/wiki/Sending-Email to start off testing to see if I could send my first email.  I used nano on my laptop then scp'd it to my router, as my router only has vi for text editing.  I am not proficient with vi, you can edit it on the ssh console on the router with vi, I'm just not the one to explain it to you.

On (my laptop, not the router ssh console screen)

nano wan-start

 

then I pasted the info below populating it with my gmail email address (2 locations FROM, AUTH), my gmail password at (PASS) and then another email address that you'll be sending too and can receive (TO)

#!/bin/sh
FROM="your-gmail-address"
AUTH="your-gmail-username"
PASS="your-gmail-password"
FROMNAME="Your Router"
TO="your-email-address"
ntpclient -h pool.ntp.org -s &> /dev/null
sleep 5
echo "Subject: WAN state notification" >/tmp/mail.txt
echo "From: "\"$FROMNAME\"" \"<$FROM>\"" >>/tmp/mail.txt echo "Date: `date -R`" >>/tmp/mail.txt echo "" >>/tmp/mail.txt echo "I just got connected to the internet." >>/tmp/mail.txt echo "" >>/tmp/mail.txt echo "My WAN IP is: `nvram get wan0_ipaddr`" >>/tmp/mail.txt echo "Uptime is: `uptime | cut -d ',' -f1 | sed 's/^.\{12\}//g'`" >>/tmp/mail.txt echo "" >>/tmp/mail.txt echo "---- " >>/tmp/mail.txt echo "Your friendly router." >>/tmp/mail.txt echo "" >>/tmp/mail.txt cat /tmp/mail.txt | sendmail -H"exec openssl s_client -quiet \ -CAfile /jffs/configs/Equifax_Secure_Certificate_Authority.pem \ -connect smtp.gmail.com:587 -tls1 -starttls smtp" \ -f"$FROM" \ -au"$AUTH" -ap"$PASS" $TO rm /tmp/mail.txt

*I had to edit the original copy&paste from the example shown on the merlin wiki to format the "from name" properly.  The one shown here should format properly.

 

I then scp'd the file to my router

scp wan-start <router-username>@<router-ip-address>:/jffs/scripts

add the switch -P <port-number> if ssh is not default port 22 on your router.

 

Back to the ssh console session on the router

Any scripts that you create, you need to make them executable.  (If you keep sending or editing the same file name over during testing, you only have to do this the first time)

chmod a+rx /jffs/scripts/*

 

If you reboot the router at this point, the script should run on start-up, or you can just run this the console

/jffs/scripts/./wan-start

 

Success!

I received an email from my router, providing me the WAN IP address and the Uptime.  Now lets see if we can email from outside of the router.

 

Email from another device on our network

We have sendmail installed by default already on the router, sendmail can also easily be installed on another device if we chose not to use a router (such as a raspberry pi, etc).  So now we can send emails from the router, we now need a way to remotely send emails using the routers sendmail setup.  There are a couple ways to accomplish this, all have their pros and cons. What I am looking for is something flexible enough, that I can send an email from a network device with minimal configuration and without the need of installing software on that device, as well as minimal setup on the gateway device (our router in this example).  Ssh and nc are what come to mind.

 

Using Sendmail

This would probably be the most logical choice, as long as our network device has or can install sendmail (or a similar mail program).  We then wouldn't need all of this work with a "middle man" as you can send directly from the device to gmail or your ISP's smtp server.  If using gmail, you would still need to download the trusted certificate to each device, but that's fairly easy to do as well.  I want the flexibility without the use of sendmail on each device.

 

Using a webserver and cgi or...?

This is also a viable option to have a webserver listen for certain commands within our network, but the router by default won't give us the ability to make all the necessary additions to allow this.  We can install entware on the router, or a webserver on a raspberry pi instead of using the router, but this requires more than what I already have running.

 

Using SSH

This is one option.  With ssh we can remotely send commands to our router, where we can call up a script and send our custom email for us.  This of course requires an ssh client on our network device, but that's probably fairly common if it lives on the network.  Our script on the router can be made flexible enough to input custom "From" and "Subject" matter to send custom messages.

We'll need to generate a key pair for use with the router so we can connect to its ssh server without the need of inputting a password.  This way we can automate the connecting and sending of an email with a script as needed from our device.

There are ways to input a password when initiating an ssh session with the use of tools such as expect, but then we would need to be sure this can be installed on our device, and would need to be installed on every device wanting to send the email.  Keys will have to on each device, but at least if it has ssh client it should support the use of keys, not sure about other programs.

 

- Generate the SSH Keypair

We need generate a public/private key pair to do this on each device that will ssh into our router.  The public key will live on the router, and the private key will live on each device that wants to connect to it.

ssh-keygen -C "<comment>"

I would populate the comment with a name to identify the host that is generating the keypair (ie: "My_Main_Laptop"), as we may have multiple keys residing on the router, and I also suggest, naming the files which can later be identified (so you remember that the private key in your folder is for the router), as well as not providing a passphrase (for use in this project)

 

Here's an example when I generated a key from my laptop, the commands I typed and comments are highlighted

me@laptop:~/.ssh$ ssh-keygen -C "My_Main_Laptop"
Generating public/private rsa key pair.
Enter file in which to save the key (/home/superuser/.ssh/id_rsa): my_router
Enter passphrase (empty for no passphrase): <-- hit enter for no passphrase
Enter same passphrase again: <-- hit enter again for no passphrase
Your identification has been saved in my_router.
Your public key has been saved in my_router.pub.
The key fingerprint is:
<xx:xx:xx:xx:xx, etc omitted for website> My_Main_Laptop
The key's randomart image is:
+--[ RSA 2048]----+
|                 |
|                 |
|                 |
|     .           |
|    . o S        |
|     o *         |
|..o + = .        |
|o* + +.=         |
| oBo+oEoo        |
+-----------------+
me@laptop:~/.ssh$ ls <-- so we can see that the files generated
known_hosts  my_router  my_router.pub
superuser@superuser-portable:~/.ssh$ cat my_router.pub <-- so we can see the comment "My_Main_Laptop"
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDXC4q6WQF+4/HFSJN3KHr7l9SiKJ5KnLa06zRy5gx0zGqRRv/ev4qRhbyqLQSPf2n/EKL8sF5pjfPU4FdeYGOEfnrJ04/m8oA3e270v1GVeb2l+TKe9QOkooBmVWis5RboawR/jlPgQlITgJyzaiMF+fzIhoo4maY4ponElmKUtEpxsIZDcPEgZ42WGxNg9ObSHLHsG5bpJqY6fZSSiN+vQuBv20vu6olb2mY0TjU5c+XfX5Iy5vbr0W5CI6zbs+0RA3Amhrp8nVLVIyvuP2/nG64RHfN02rQvBZpMM0OtHmnaws6evy0syMKt1aa0+1TqPdscWyODZtsP2Jinw32X My_Main_Laptop

 

- Install the public key onto the router

You'll need to copy and paste the contents of *.pub file you just generated into the web interface of the router.  Goto Administration > System and scroll down to SSH Authentication key, paste it in, andhit apply.

Now when we ssh into the router from our laptop, we are not prompted to input a password.  Now we need to create a script on the router that we can execute remotly and pass along some variables for some custom emails.

 

Create a script on the router to accept remote device commands

 Using the test script from above as our guide, we will implement a few new features, while eliminating the ones we don't need.

  • I want the ability to change the sender's name (Router, Weather_Station, NAS, APRS, etc) as this will serve any device that I want to use it with
  • I want the ability to customize the subject line and body of the email, either from command line or a file
  • I want to have a default option as well, if I don't want any customization other than a quick notification,  a subject line must be custom, all other variables can be left to a generic default

Although you can use sendmail from the command line as it stands, this wrapper script will give it more flexibilty and ease of use.  You don't have to worry about proper formatting, and inputting uneccesary info, only basic information such as a subject line and message.

Creating the script had it's own challenges, especially as I am not a shell scripting guru by any means.  I originally wanted to use getopt, which would allow me to pass variables into the script with switches (-f, -s) etc to define specific custom fields I wanted to populate.  It appears my busybox on the router does not have getopt installed.  I also ran into many issues attempting to make it compatible for both bash an sh shells, as there are many differences between the two when it comes to writing scripts of this nature.

I did a lot of testing it in both sh and bash shells (sh is what is on the router) and it appears to work for my needs.  I imagine there may be some bugs that could pop out when reading from files, but I did the best I could to check for errors.

Here's the script below.  This will be put onto the router which we can call up with our custom arguments and switches to define what fields we will populate

#!/bin/sh
################################################################################
# Tested in bash and sh
# Change shebang #!/bin/bash or #!/bin/sh as needed
# Requires sendmail to be installed on the system
#
# -Algis Salys algissalys.com
################################################################################
################################################################################
# Variables you NEED to change
################################################################################
FROM=""                    # Your gmail address    This email address is being protected from spambots. You need JavaScript enabled to view it.
AUTH=""                   # Your gmail login    This email address is being protected from spambots. You need JavaScript enabled to view it.
PASS=""                   # Your gmail password
DTO=""                     # Default Send-To Email Address

################################################################################
EMAILSERVER="smtp.gmail.com:587"                # Change if other than gmail
################################################################################
################################################################################
# Default Values - edit as needed
################################################################################
DSENDER="Your Network"                        # Default Sender Name
DBODY="Today's \"date\" is\n...\nDate: `date -R`"        # Default Body                        
DCERT="/jffs/configs/Equifax_Secure_Certificate_Authority.pem"    # Default Cert File
################################################################################

usage()
{
cat << EOF
This script will send an email using sendmail.
Usage: $0 -s '<subject line>' [<OPTIONS>] '<argument>' ...
       -s "<subject line>" is required
OPTIONS:
   -h --help   Show this message
   -t          Recipient's Address (Send email To:)
   -f          Sender's Name
   -s          Subject line
   -b          Body of the email
   -r          Read txt file to put into body of email
Examples:
  ./send-email -t 'This email address is being protected from spambots. You need JavaScript enabled to view it.' -f 'Jimmy John' -s 'Weather Update' -b 'Temp: 79F\nHumidity: 40%\n'
  ./send-email -s 'The eagle has landed'
Defaults:
  Recipient's Address: $DTO
  Sender's Name:       $DSENDER
  Body of the email:   $DBODY
EOF
}
################################################################################
# Check if needed values are populated
################################################################################
if [ -z "$FROM" ] || [ -z "$AUTH" ] || [ -z "$PASS" ] || [ -z "$DTO" ]
then
     echo "Default values at the top of the script must all be populated"
     exit 1
elif [ -z "$EMAILSERVER" ]
then
     echo "No email server specified at the top of the script"
     exit 1
elif [ ! -f "$DCERT" ]
then
     echo "Certificate file $DCERT not found!"
     exit 1
fi
################################################################################
# Parse Input
################################################################################
emailopts="$@"
flag=0
parse=0

for index in ${emailopts}
    do
    case "$flag" in
          1)
               parse=1
               ;;
          2)
               parse=2
               ;;
          3)
               parse=3
               ;;
          4)
               parse=4
               ;;
          5)
               parse=5
               ;;
    esac
    case "$index" in
         -h)
               usage
               exit 1
               ;;
         --help)
               usage
               exit 1
               ;;
         -f)
               flag=1
               parse=0
               ;;
         -s)
               flag=2
               parse=0
               ;;
         -b)
               flag=3
               parse=0
               ;;
         -t)
               flag=4
               parse=0
               ;;
         -r)
               flag=5
               parse=0
               ;;
    esac
    case "$parse" in
          1)
               if [ -z "$SENDER" ]
               then
                   SENDER="$index"
               else
                   SENDER="$SENDER $index"
               fi
           ;;
          2)
               if [ -z "$SUBJECT" ]
               then
                   SUBJECT="$index"
               else
                   SUBJECT="$SUBJECT $index"
               fi
           ;;
          3)
               if [ -z "$BODY" ]
               then
                   BODY="$index"
               else
                   BODY="$BODY $index"
               fi
           ;;
          4)
               if [ -z "$TO" ]
               then
                   TO="$index"
               else
                   TO="$TO $index"
               fi
           ;;
          5)
               if [ -z "$FILE" ]
               then
                   FILE="$index"
               else
                   FILE="$FILE $index"
               fi
           ;;
    esac
done
################################################################################
# Check and Parse For Attached File
################################################################################
if [ ! -z "$FILE" ]
then
    if [ ! -f "$FILE" ]
    then
        echo "File $FILE not found!"
        exit 1
    else
        if [ -z "$BODY" ]
        then
            BODY=`cat $FILE`
        else
            TEMP=`cat $FILE`
            BODY="$BODY\n$TEMP"
        fi
    fi
fi
################################################################################
# Load Default Values if empty
################################################################################
if [ -z "$SUBJECT" ]
then
     usage
     exit 1
fi
if [ -z "$SENDER" ]
then
     SENDER="$DSENDER"
fi
if [ -z "$TO" ]
then
     TO="$DTO"
fi
if [ -z "$BODY" ]
then
     BODY="$DBODY"
fi
################################################################################
# Send Email
################################################################################
echo "Subject: $SUBJECT" >/tmp/mail.txt
echo "From: "\"$SENDER\"" \"<$FROM>\"" >>/tmp/mail.txt
printf "$BODY" >>/tmp/mail.txt
printf "\n" >>/tmp/mail.txt
cat /tmp/mail.txt | sendmail -H "exec openssl s_client -quiet \
-CAfile "$DCERT" \
-connect "$EMAILSERVER" -tls1 -starttls smtp" \
-f"$FROM" \
-au"$AUTH" -ap"$PASS" $TO

rm /tmp/mail.txt

 

I'd love to hear feedback on anything I may have done incorrectly, or better ways to do this in a shell script.  Tell me what you think!  I understand there are many ways of doing this more efficiently, but again my needs were to make it as cross platform as I knew how, with using as few external programs as possible (perl, python, etc)

 

- Installing the script

  • Copy and paste the script using your text editor (such as nano)
  • Edit the top #!/bin/sh to #!/bin/bash if using a bash shell (Most newer linux distributions use bash, smaller embedded systems may use sh)
  • Populate the four variables in quotes that are required with your information

example:

FROM="This email address is being protected from spambots. You need JavaScript enabled to view it."                    # Your gmail address    This email address is being protected from spambots. You need JavaScript enabled to view it.
AUTH="This email address is being protected from spambots. You need JavaScript enabled to view it."                   # Your gmail login    This email address is being protected from spambots. You need JavaScript enabled to view it.
PASS="mySecreTPa$$word"                   # Your gmail password
DTO="This email address is being protected from spambots. You need JavaScript enabled to view it." # Default Send-To Email Address
  • If you need to send it to you router or other device, in linux, I use scp
scp <file-name-to-send> <router-user-name>@<router-ip>:<directory-on-router-to-copy-script>

example:

scp router_scripts/send-email This email address is being protected from spambots. You need JavaScript enabled to view it..1.1:/jffs/scripts
  • Make the script executible on the device it will run on
chmod a+rx send-email

 

- Using the script

Locally where the script is installed, to get basic help

./send-email -h

Command line Email Gateway 05

A Subject line must be given for any email, everything else will write generic item's from the script in the email

./send-email -s 'This Is An Important Email!'

Command line Email Gateway 06

Send an email with custom Subject, Body, and From arguments. *Note bash shell does not handle exclamation points very well ("!") if followed by a backslash as shown in the example below, I didn't find issue in the sh shell

./send-email -s 'This Is not a very important email"' -f 'My Blueberry Pi' -b 'Hello\nWorld!\nThis Is Not A Test'

Command line Email Gateway 07

Using the script from a remote device with ssh

Using ssh, and now setup with our key pairs per the instructions above, we can now send an email from another device.  Be sure to escape any double quotes that you may have in your arguments (\").

ssh <router-username>@<router-ip-address> "<directory-where-script-is-installed>/./send-email -s 'This is our Subject Line'"

 examples:

ssh This email address is being protected from spambots. You need JavaScript enabled to view it..1.1 "/jffs/scripts/./send-email -s 'This is our Subject Line'"
 ssh This email address is being protected from spambots. You need JavaScript enabled to view it..1.1 "/jffs/scripts/./send-email -s 'This is our Subject Line' -f 'My Laptop' -b 'Hello\nWorld! The is just another test'"

 

 Troubleshooting

I tested this wrapper shell between my laptop running Ubuntu 14.04 and my router running Asuswrt.  The only issue I found so far is using an exclamation point followed by a backslash (!\)when issuing the command via ssh from a bash shell.  If anyone knows of an easy fix, let me know.

 

- Are you sure you want to continue connecting?

One thing I had an issue with from my laptop was I kept receiving "Are you sure you want to continue connecting (yes/no)?", every time I ssh into the router, if you don't receive that message every time, that's a good thing!  You should only recieve it the first time you SSH into a particular device, if you continue to recieve it every time you log in after, as I was, there may be something wrong with your known_hosts file.
You can remove this file ~/.ssh/known_hosts if you continue to see this message when you initiate the ssh session, if you do decide to remove it, any new ssh sessions will ask this message again only the first time you log in.  Keep in mind, only do this if you are on your own network, these known_hosts help protect that you are connecting to the correct machine (and not someone else's machine)

 

To remove the hosts file

mv ~/.ssh/known_hosts known_host.old

This will rename it to an unused file and a new known_hosts file will be created once you initiate a new ssh session.

 

Conclusion

I can now easily, without the worry of proper formatting, trusted certificates, remembering all of the specifics, email from many devices to add functionality in both past and future projects.  Sendmail and other mail programs can be used in a similar one line fasion, but only basic sendmail is installed on my router and difficult to remember parameters when utilizing ssl connections wasn't what I was wanted.  With the help of the wrapper script, it gives me the flexibility and simplicity I was after.  Overkill, maybe a little but it was a fun project.  It was a very good exercise in shell scripting and I learned a lot from this.  There are other things I do want to implement, and will update as I have time.  Specifically the use of netcat.  My router already as netcat, and it may be easier to install on some devices vs an ssh client.  The downside would  be opening up a security whole with nc running on the router, and although it's on my home network, this may not be the best idea.  It's something to think about if I see the need arising in any projects.  I think for now I'm satisfied with what this script can do and the flexibility it brings working alongside with sendmail and ssh.

 

References

https://github.com/RMerl/asuswrt-merlin/wiki/Sending-Email

https://rsalveti.wordpress.com/2007/04/03/bash-parsing-arguments-with-getopts/

and many, many http://stackexchange.com/ and http://stackoverflow.com/ posts, thank you, whoever you are!

Read 4997 times Last modified on Monday, 05 October 2015 15:52
Algis Salys

Creator and owner of algissalys.com.  Linux enthusiast, electronics tinkerer, and likes to spend time in the workshop building and creating new projects.