Solved

Looking for a Linux wrapper script

Posted on 2014-03-14
2
333 Views
Last Modified: 2014-03-17
Hello,
This may be difficult but what I'm looking for is a linux shell script that I can use as a wrapper to notify me when something completes. I realize I will have to adjust script to key off a certain word for script to notice completion. I also would like a section to key off of for failure so that I can be notified of completion or failure.
As for notification we currently use /etc/alias and I can just use my account already setup in there.
Does anyone have a wrapper already created I could have? Or could someone point me in the direction of how to create my own?
Im also wondering how the wrapper works? Do I call the program or command I want notification from within the wrapper?

Thanks!
0
Comment
Question by:k3vsmith
2 Comments
 
LVL 48

Accepted Solution

by:
Tintin earned 500 total points
ID: 39930879
Assuming you are using the wrapper to launch the script, then use something like:

#!/bin/bash
CMD="$*"

$CMD

if [ $? -eq 0 ]
then
     echo "$CMD completed successfully" | mail -s "Command completed" user@example.com
else
     echo "$CMD failed" | mail -s "Command failed" user@example.com
fi

Open in new window


Then call the wrapper script with the appropriate command and arguments, eg:

wrapper.sh /path/to/command arg1 arg2
0
 

Author Comment

by:k3vsmith
ID: 39935294
Ok this will most likely work for what I need it for. Thanks!
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction We as admins face situation where we need to redirect websites to another. This may be required as a part of an upgrade keeping the old URL but website should be served from new URL. This document would brief you on different ways ca…
Setting up Secure Ubuntu server on VMware 1.      Insert the Ubuntu Server distribution CD or attach the ISO of the CD which is in the “Datastore”. Note that it is important to install the x64 edition on servers, not the X86 editions. 2.      Power on th…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question