Solved

Looking for a Linux wrapper script

Posted on 2014-03-14
2
338 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Background Still having to process all these year-end "csv" files received from all these sources (including Government entities), sometimes we have the need to examine the contents due to data error, etc... As a "Unix" shop, our only readily …
I. Introduction There's an interesting discussion going on now in an Experts Exchange Group — Attachments with no extension (http://www.experts-exchange.com/discussions/210281/Attachments-with-no-extension.html). This reminded me of questions tha…
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.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

733 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