Solved

Looking for a Linux wrapper script

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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
Google Drive is extremely cheap offsite storage, and it's even possible to get extra storage for free for two years.  You can use the free account 15GB, and if you have an Android device..when you install Google Drive for the first time it will give…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
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…

688 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