Creative COW SIGN IN :: SPONSORS :: ABOUT US :: CONTACT US
FORUMS: listlist (w/ descriptions)archivetagssearchhall of famerecent posts

re: 00_msg sample script

Cow Forums : Telestream Episode

<< PREVIOUS THREAD   •   VIEW ALL THREADS   •   PRINT   •   NEXT THREAD >>
re: 00_msg sample script
by Evan Scheck on Nov 18, 2008 at 9:39:06 pm

I have tried to use the sample script in the evt/examples folder but it doesn't seem to be working. I edited the Unix executable file in Terminal and changed only the recipient e-mail address and saved it in the evt directory. I have restarted my engine and all input monitors yet nothing happens when a job fails. Do I need to setup a real e-mail account to send from on my server? And then also make that the "from" in the script?

I have been working on this issue on and off for months now and have no solutions. Thanks for your help!



Respond to this post   •   Return to posts index

Re: re: 00_msg sample script
by Robert Longwell on Nov 18, 2008 at 9:55:10 pm

Let me see if I can get the right person with the info for you...

Robert Longwell


Respond to this post   •   Return to posts index

Re: re: 00_msg sample script
by Andy Bauch on Nov 18, 2008 at 10:32:25 pm

Hi Evan,

We've had this working for a few months now. I think the first step is to confirm that you can successfully send an e-mail from the command line. Are you able to do this? Try executing the command below from a Terminal (after filling in the e-mail address) and see if the message shows up in your inbox.

echo -e "To: youremail@yourdomain.comnSubject: Test MessagennTest Message Body" | sendmail -t -F "Episode Engine" -f "Episode_Engine@yourdomain.com"

Also, do you have an SMTP server you would like to use to route your e-mail?

-Andy



Respond to this post   •   Return to posts index


Re: re: 00_msg sample script
by Robert aka Fixer Smith on Nov 19, 2008 at 1:27:25 am

looks like the forum munged your post a bit. Make sure those extra "n"'s are really "n" which is unix for "new line here"


echo -e "To: youremail@yourdomain.comnSubject: Test MessagennTest Message Bodyn" | sendmail -t -F "Episode Engine" -f "Episode_Engine@yourdomain.com"




Respond to this post   •   Return to posts index

Re: re: 00_msg sample script
by Andy Bauch on Nov 19, 2008 at 1:45:29 am

Thank you Robert. Ughhh stupid HTML.

Hopefully this will preserve the backslashes...

echo -e "To: youremail@yourdomain.com\nSubject: Test Message\n\nTest Message Body" | sendmail -t -F "Episode Engine" -f "Episode_Engine@yourdomain.com"





Respond to this post   •   Return to posts index

Re: re: 00_msg sample script
by Evan Scheck on Nov 20, 2008 at 7:27:57 pm

Thanks for responding guys. So I tried this latest command (with the slashes) and while I didn't get an error in terminal, I also didn't get anything in my inbox. I replaced both the recipient address and changed the domain on the sender address.

We use an Exchange server at my job so I suppose it would have to be routed through that.



Respond to this post   •   Return to posts index


Re: re: 00_msg sample script
by Robert Longwell on Nov 20, 2008 at 7:39:09 pm

You may actually have to setup an SMTP server to handle these emails. That is usually the standard for servers to communicate emails through, not Exchange.

Robert Longwell


Respond to this post   •   Return to posts index

Re: re: 00_msg sample script
by Evan Scheck on Nov 20, 2008 at 7:46:27 pm

Okay, so it took a while, but I can say now that the e-mail did come through. So we know that's working with no add'l setup. Any other advice?



I just setup a job I knew would crash (faulty transcode setting) and I am not sure if the script kicked into gear. Is there anything that alerts you the script is present or executing? Also, I'm not sure if stop-fail or drop-fail are picked up by meeting the required severity. What should I do to make that proper?

Respond to this post   •   Return to posts index

Re: re: 00_msg sample script
by Andy Bauch on Nov 20, 2008 at 9:57:58 pm

Aha! I think I see a potential solution here. We don't actually use 00_msg to notify us of failed jobs, we use 00_job

Let's forget about 00_msg for the time being, and try appending the following code to your 00_job file and then failing a job:

if [ "$JOB_REASON" != "finish" ]; then
     echo -e "To:your.email@domain.comnSubject: Job '$JOB_NAME' failednnJob '$JOB_NAME' with id $JOB_ID dropped with reason: $JOB_REASON" | sendmail -t -F "Episode Engine" -f "Episode_Engine@yourdomain.com"

     echo "SUCCESS!!!" >> /tmp/00_job.out
fi


When a job fails this should send an e-mail notification to you and it should also write to a file in the /tmp directory called 00_job.out. You can check the contents of that file easily from the command line by typing:
cat /tmp/00_job.out
Let me know if that works...

Also, until we setup sendmail to route through an SMTP server our e-mails took a long time to deliver as well. Now they are almost instantaneous. The setup is easy, just edit the file /etc/postfix/main.cf (you will probably have to do this as root or using sudo) and add a line:
relayhost = your.smtp.server.ip





Respond to this post   •   Return to posts index


Re: re: 00_msg sample script
by Evan Scheck on Nov 20, 2008 at 10:27:45 pm

Andy,

You are the man! This seems to have worked like a charm. I just got the following e-mail:

if [ "fail" != "finish" ]; then
echo -e "To:escheck@grey.comnSubject: Job '[regular] DVTest: DV25_NTSC.setting + WIRELESS_pc.mov' failednnJob '[regular] DVTest: DV25_NTSC.setting + WIRELESS_pc.mov' with id 802 dropped with reason: fail" | sendmail -t -F "Episode Engine" -f "episode@grey.com"

echo "SUCCESS!!!" >> /tmp/00_job.out
fi

Job '[regular] DVTest: DV25_NTSC.setting + WIRELESS_pc.mov' with id 802 dropped with reason: fail


I took the liberty of changing the "n"s in your script to "n"s as directed in the earlier post too. Is there anything on this script in the sections above that maybe I don't need and can get either deleted or hashed out? I would just like to keep things as simple and functional as possible. Also, would you mind if I e-mailed you the whole script (or posted it) for review to make sure I didn't stick any lines of code in the wrong place?

A couple more questions...what would be the proper syntax to have multiple e-mail recipients of this fail notice? Also, will this script work on jobs submitted to an Input Monitor too? So far I could only test something in the Input folder.

Thanks for all your help! This forum has come a long way from a year ago!




Respond to this post   •   Return to posts index

Re: re: 00_msg sample script
by Andy Bauch on Nov 21, 2008 at 7:36:29 pm

That's great Evan!

There are definitely parts of the script you can delete (for instance the echo "SUCCESS" line, which was just for testing purposes). Please post the script in its entirety and I'll let you know what can be chopped. Also, you may wish to remove the 00_job.out file which was created by the test script. To do so you can run this command:
rm /tmp/00_job.out

And yes, your script should work for both hot folders and input monitors.

-Andy



Respond to this post   •   Return to posts index

Re: re: 00_msg sample script
by Evan Scheck on Dec 1, 2008 at 4:18:36 pm

#!/bin/bash
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# TELESTREAM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE

# EXAMPLE SCRIPT DEMONSTRATING THE USE OF JOB EVENTS
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Job events are sent when a job is finished or failed.

# PRE-SET ENVIRONMENT VARIABLES
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# client_name - name of the client who submitted the job.
# client_host - hostname of the client who submitted the job.
# owner - username of the job submitter.
# job_name - name of job (set by client).
# job_media - name of input media file.
# job_setting - name of the setting file.
# job_kind - kind of job. "regular", "split" or "stitch".
# job_folder - if the job was submitted by the watcher (from a watch folder),
# only the folder name is set. If it's submitted through
# some other client, the full path of the folder is set.
#
#
# JOB_NAME - same as job_name (exists for backwards compatibility)
# JOB_SOURCE_FILE - same as job_media (exists for backwards compatibility)
# JOB_ID - an ID decided by Episode Engine.
# JOB_NODE_ID - the ID of the last node that ran the job.
# JOB_PRIO - job priority.
# JOB_RUN_COUNT - the number of times the job was processed, normally 1.
# JOB_CREATION_TIME - a UNIX timestamp set when the job was created.
# JOB_START_TIME - a UNIX timestamp when the job was (last) started.
# JOB_STOP_TIME - a UNIX timestamp when the job was (last) stopped.
# JOB_REAL_TIME - the final processing time in seconds of the last run.
# JOB_SETTING_NAME - same as job_setting (exists for backwards compatibility)
# JOB_OUT_FOLDER - same as job_folder (exists for backwards compatibility)
# NOTE: this is set even if the job failed.
#
# If the job finished without errors, the JOB_REASON is set to "finish"
# and the following three variables are set:
#
# JOB_OUT_PATH - the path to the final output file for this job.
# JOB_OUT_URL - the URL to the final output file for this job.
#
#
# JOB_REASON is one of the following string values:
# "no-start"
# "bad-com"
# "bad-job"
# "fail"
# "crash"
# "lost"
# "cancel"
# "finish"
#

USER="anonymous"
PASSWORD="anonymous"
HOST="example.com"

ADDRESS="ftp://${USER}:${PASSWORD}@${HOST}/"

RETURN_CODE=0

# Check if the job completed successfully
if [ "$JOB_REASON" == "finish" ]; then
# Create temp file for FTP server directory listing (to see if upload was successful)
TEMPFILE=`/usr/bin/mktemp /tmp/ftp_XXXXXX`
# Extract file name to use for naming file on FTP server
FILENAME=`/usr/bin/basename "$JOB_OUT_PATH"`
# Connect, set binary mode, upload file, list directory, close connection.
/usr/bin/ftp -iv "${ADDRESS}" << EOF
binary
put "${JOB_OUT_PATH}" "${FILENAME}"
ls . "$TEMPFILE"
quit
EOF
# Check if file existsin the FTP directory listing
if /bin/cat "$TEMPFILE" | /usr/bin/grep "$FILENAME" >/dev/null 2>&1; then
# FTP upload ok
RETURN_CODE=0
else
# FTP upload failed
RETURN_CODE=1
fi
# Remove temporary file again
/bin/rm "$TEMPFILE" >/dev/null 2>&1
else
# Send mail to admin about the failed job
RECIPIENT="escheck@grey.com"
MESSAGE="Job '$JOB_NAME' with id $JOB_ID dropped with reason: $JOB_REASON"
/usr/sbin/sendmail $RECIPIENT << EOF
From: "Episode Engine"
Subject: Job '$JOB_NAME' failed

if [ "$JOB_REASON" != "finish" ]; then
echo -e "To:escheck@grey.comnSubject: Job '$JOB_NAME' failednnJob '$JOB_NAME' with id $JOB_ID dropped with reason: $JOB_REASON" | sendmail -t -F "Episode Engine" -f "episode@grey.com"

echo "SUCCESS!!!" >> /tmp/00_job.out
fi

$MESSAGE
EOF
fi

exit $RETURN_CODE

--------------

That's what I have in there at present. It's working, but if I should chop it down some then I will. Also, I've noticed that when a file is placed in the input monitor it updates many times until it's fully there, then says "ripe." Is this normal. Anyway to limit the amount of times the update line is displayed? It would make tracking things a lot easier to not see that.

Thanks again for all your help and hope you had a great holiday!



Respond to this post   •   Return to posts index


Re: re: 00_msg sample script
by Andy Bauch on Dec 2, 2008 at 12:56:39 am

You can eliminate this entire block:


if [ "$JOB_REASON" != "finish" ]; then
echo -e "To:escheck@grey.comnSubject: Job '$JOB_NAME' failednnJob '$JOB_NAME' with id $JOB_ID dropped with reason: $JOB_REASON" | sendmail -t -F "Episode Engine" -f "episode@grey.com"

echo "SUCCESS!!!" >> /tmp/00_job.out
fi


Then test again by failing a job and ensuring that you still get an e-mail (this time without extraneous code in the body of the message).

I realized that I never answered your question above about the syntax for multiple e-mail recipients. Simply separate the addresses with commas. In other words, change the line RECIPIENT="escheck@grey.com" to read:
RECIPIENT="escheck@grey.com,recipient.two@grey.com,recipient.three@grey.com"



Respond to this post   •   Return to posts index

<< PREVIOUS THREAD   •   VIEW ALL THREADS   •   PRINT   •   NEXT THREAD >>


FORUMSTUTORIALSMAGAZINETRAININGVIDEOS - REELSPODCASTSEVENTSSERVICESNEWSLETTERNEWSBLOGS

© CreativeCOW.net All rights are reserved.

[Top]