The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
plz help me in writing a script Renjesh SUN Solaris 3 03-24-2008 08:31 AM
File queue script GMMike Shell Programming and Scripting 2 10-23-2007 08:19 AM
Writing the script jess_t03 Shell Programming and Scripting 1 10-10-2007 06:17 AM
help writing script dr46014 Shell Programming and Scripting 8 08-27-2007 05:08 AM
shell script needed for mail queue notification Nightman Shell Programming and Scripting 10 03-07-2007 05:37 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rating: Thread Rating: 1 votes, 4.00 average. Display Modes
  #1 (permalink)  
Old 06-01-2009
ITAdmin08 ITAdmin08 is offline
Registered User
  
 

Join Date: Jun 2009
Posts: 8
Need Help Writing Script To Email When Fax Queue Goes Down

I need a script that would email me when the fax queue goes down. How would I go about doing this? Our fax queue drops a few times a week and if I don't catch it fairly quickly it gets backed up really fast which makes the users a little unhappy...

I am new to Unix-AIX.

We are running Unix-AIX 6 running Activant Eclipse ERP
We also have an Exchange Email Server which is used to email orders from the Eclipse System on UNIX.

I would appreciate any help on this!!
  #2 (permalink)  
Old 06-01-2009
TonyFullerMalv's Avatar
TonyFullerMalv TonyFullerMalv is offline Forum Advisor  
Registered User
  
 

Join Date: Sep 2008
Location: Malvern, Worcs. U.K.
Posts: 740
Presumably when the FAX queue has "gone down" it no longer send faxes?
How do you tell from within Unix that the FAX queue has "gone down"?
What do you then do to fix the fax queue because that could be automated also?
  #3 (permalink)  
Old 06-02-2009
ITAdmin08 ITAdmin08 is offline
Registered User
  
 

Join Date: Jun 2009
Posts: 8
Quote:
Originally Posted by TonyFullerMalv View Post
Presumably when the FAX queue has "gone down" it no longer send faxes?
How do you tell from within Unix that the FAX queue has "gone down"?
What do you then do to fix the fax queue because that could be automated also?
Correct, faxes cease to be sent out when the queue goes down.
The state of the device "modem1" goes to "not running" I run vfxstat -a to see the status of the modems.
I run a command that was created before I started here called "fixfax" which restarts the vsi-fax service.

Could I do some sort of IF > THEN statement? I don't have much script writing experience at all.

Last edited by ITAdmin08; 06-02-2009 at 09:27 AM..
  #4 (permalink)  
Old 06-02-2009
TonyFullerMalv's Avatar
TonyFullerMalv TonyFullerMalv is offline Forum Advisor  
Registered User
  
 

Join Date: Sep 2008
Location: Malvern, Worcs. U.K.
Posts: 740
Okat here goes:

Code:
#!/bin/sh
PATH=/usr/bin:/path/to/fax/commands
export PATH

FAXSTATUS=`vxfstat -a`
FAXTEST=`echo "${FAXSTATUS}" | grep "not running"`
if [ -n "${FAXTEST}" ]; then
  date > /tmp/mailfile
  echo "Fax not running." >> /tmp/mailfile
  echo "Status =" >> /tmp/mailfile
  echo ${FAXSTATUS} >> /tmp/mailfile
  fixfax
  sleep 3
  echo "Status after running fixfax =" >> /tmp/mailfile
  vxfstat -a >> /tmp/mailfile
  mailx -s "Fax has gone down" user@domain.com < /tmp/mailfile
fi

Replace /path/to/fax/commands with the path to vxfstat and fixfax.
Replace the email address with the one (or more with comma delimiters) that the message should go to.

Call this from cron at suitable regular intervals as the user that can get the status and run fixfax and it may be self healing as well as emailing that the fax queue went down.
  #5 (permalink)  
Old 06-03-2009
ITAdmin08 ITAdmin08 is offline
Registered User
  
 

Join Date: Jun 2009
Posts: 8
Quote:
Originally Posted by TonyFullerMalv View Post
Okat here goes:

Code:
#!/bin/sh
PATH=/usr/bin:/path/to/fax/commands
export PATH

FAXSTATUS=`vxfstat -a`
FAXTEST=`echo "${FAXSTATUS}" | grep "not running"`
if [ -n "${FAXTEST}" ]; then
  date > /tmp/mailfile
  echo "Fax not running." >> /tmp/mailfile
  echo "Status =" >> /tmp/mailfile
  echo ${FAXSTATUS} >> /tmp/mailfile
  fixfax
  sleep 3
  echo "Status after running fixfax =" >> /tmp/mailfile
  vxfstat -a >> /tmp/mailfile
  mailx -s "Fax has gone down" user@domain.com < /tmp/mailfile
fi

Replace /path/to/fax/commands with the path to vxfstat and fixfax.
Replace the email address with the one (or more with comma delimiters) that the message should go to.

Call this from cron at suitable regular intervals as the user that can get the status and run fixfax and it may be self healing as well as emailing that the fax queue went down.

looks like this will work. only problem is when fixfax is run it requires you to hit the enter key, is there a way to do that? Could I just leave out fixfax? I really just need it to notify me.
  #6 (permalink)  
Old 06-03-2009
TonyFullerMalv's Avatar
TonyFullerMalv TonyFullerMalv is offline Forum Advisor  
Registered User
  
 

Join Date: Sep 2008
Location: Malvern, Worcs. U.K.
Posts: 740
It will be a case of trying a few things, e.g.:

Code:
echo "" | fixfax

or


Code:
fixfax <<EEOOFF

EEOFF

Note the intentional blank line, which is the carriage return/enter character.

or:
Put the following into a file called fixfax.exp and call it from the original script instead of calling fixfax directly:

Code:
#!/usr/bin/expect
spawn /path/to/fixfax
expect "please press enter:"
send "\r"
expect eof

Confirm where expect is installed on your system and change the header accordingly.
Confirm what text fixfax spits out before wanting the enter key hit and the change the
expect "please press enter:" line accordinlgy.

Last edited by TonyFullerMalv; 06-03-2009 at 05:08 PM.. Reason: Formatting
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 04:00 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0