Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4027848
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T11:08:51+00:00 2026-05-20T11:08:51+00:00

I use Ubuntu and am trying to write a script that makes the following:

  • 0

I use Ubuntu and am trying to write a script that makes the following:
-test if an audio stream works
-if not, send an email.

I have tried the following code (running as a cron job every 10 minutes), which ‘works’ if I supply the wrong pw e.g.(it sends an email then), but does nothing if the actual server is down (tested by killing the server). any ideas on how to fix the script?
Thanks in advance!

#!/bin/bash
#servertest.sh


username=user1
password=xyz


url="http://wwww.streamingaudioserver.com -passwd $password -user $username"

mplayer $url &
sleep 5

test=$(pgrep -c mplayer)

if [ $test = 0 ]; then
    #server is down!
    mailfile="downmail.txt"
    /usr/sbin/ssmtp test@maildomain.com < "/home/test/$mailfile"  
fi

killall mplayer
sleep 5

exit
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T11:08:52+00:00Added an answer on May 20, 2026 at 11:08 am

    Your problem is in this line:

    $mailfile="downmail.txt"
    

    remove the dollar sign and that should do it.

    You should be getting error messages in your cron log or emails to the crontab owner complaining about a command not found or no such file.

    Edit:

    Does your script work if run from the command line (with the stream down) rather than cron?

    Try using set -x (or #!/bin/bash -x) in the script to turn on tracing or use echo "PID: $$, value of \$test: $test" > /tmp/script.out after the assignment to see if you’re getting the zero you’re expecting.

    Also, try an ssmtp command outside the if to make sure it’s working (but I think you already said it is under some circumstances).

    Try your script without ever starting mplayer.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm on laptop (Ubuntu) with a network that use HTTP proxy (only http connections
I'm trying to use s3cmd on ubuntu 10.04 to sync with a local folder.
I'm running a Linux Ubuntu 10.4 VM using VirtualBox. I'm trying to use oprofile
My Ubuntu server has Apache and Subversion installed. I use this server as a
I have an Ubuntu Server (with all of LAMP and Subversion installed). I use
We use a data acquisition card to take readings from a device that increases
I'm trying to write my first ever bit of AJAX, reading the public tmeline
I am trying to work on a Python library that is already installed on
I have a Perl script on a Linux (Ubuntu 8.10) machine and I need
I'm trying to write in file ~/.log but file is remaining empty. I don't

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.