Solved

Looking for a Linux wrapper script

Posted on 2014-03-14
2
328 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Over the last ten+ years I have seen Linux configuration tools come and go. In the early days there was the tried-and-true, all-powerful linuxconf that many thought would remain the one and only Linux configuration tool until the end of times. Well,…
Recently, an awarded photographer, Selina De Maeyer (http://www.selinademaeyer.com/), completed a photo shoot of a beautiful event (http://www.sintjacobantwerpen.be/verslag-en-fotoreportage-van-de-sacramentsprocessie-door-antwerpen#thumbnails) in An…
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…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

746 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now