1826235 Members
2781 Online
109692 Solutions
New Discussion

Re: Script help - Vsifax

 
SOLVED
Go to solution
Shar Hunter
Frequent Advisor

Script help - Vsifax

Hello All,

I need help writing a script. We have an application called VSIFax running on our system. It is a fax server. Well the server dies (software stops running, not the actual Unix server!).

To check if the VSIFax software is running I type
#vfxstat -r
If it says the server is down I can re-start it by typing
#vfxsched start

What or how do I write a script to periodically check if the
software is up, if not then to re-start it.

I have a similar problem with a printer that for some reason gets disabled? I want to check to see if the printer is disabled, if so then to enable it.

I know a script will accomplish this, and I can schedule the script in crontab. But I have barely any idea how to write the script (even though I bet it is easy).

Any help would be appreciated.

Thanks,

Troy Hicks
I don't think I'm in Kansas anymore.
13 REPLIES 13
James R. Ferguson
Acclaimed Contributor

Re: Script help - Vsifax

Hi Troy:

If I assume that the process running is called "VSIFax" then I could write something like this:

if [ -z "`UNIX95= ps -C VSIFax|awk 'NR>1 {print $1}'`" ]
then
echo "Fax process isn't running!"
else
echo "Fax process is alive"
fi

For the printer you want to check, you could do something like:

if [ `lpstat -p|awk '/myprinter/ {print $3}'` = disabled ]
then
echo "printer is disabled"
else
echo "printer is enabled"
fi

Regards!

...JRF...
Steve Post
Trusted Contributor

Re: Script help - Vsifax

I used to use vsifax on an IBM RS6000. But I don't have my notes here (they're at home). There is a log for vsifax that may give you the reason why vsifax is dying. If it is due to a bad phone number, it should fail on the fax, but still keep vsifax RUNNING. There is a vfxolog that tells you how the outbound faxes went, to include their failures. I think there's a vfxilog too.

On making a script to restart vsifax, I think it came with one (vfxstart.sh?). There is an environmental file (under /etc) you need to source in your reset script. (i.e.

#!/bin/ksh
. /etc/vsifax.env



There should be a spot where the inbound and outbound faxes are copied to. Maybe this area is full?

Just some ideas.
Steve
A. Clay Stephenson
Acclaimed Contributor

Re: Script help - Vsifax

Hi Troy,

You are in luck. I happen to run vsifax. Your script should look very much like this

#!/usr/bin/sh


VSIFAX=/opt/vsifax3
PATH=${PATH}:/usr/bin:/usr/sbin:${VSIFAX}/bin
export VSIFAX PATH

STAT=0
vfxstat -r | grep -q "is running"
VSTAT=$?
if [ ${VSTAT} -ne 0 ]
then
vfxsched start
STAT=$?
fi
exit ${STAT}

That should do it, Clay
If it ain't broke, I can fix that.
Shar Hunter
Frequent Advisor

Re: Script help - Vsifax

I have not gotten any of this to work YET. James I used this script to test for the printer:

#!/usr/bin/sh

if [`lpstat -p|awk '/lp17/ {print $3}'` = disabled ]
then
enable lp17
fi

But when I run it I get this message:
(When the printer is already disabled)
/rd/bin/enablelp17[3]: [disabled: not found.
When the printer is enabled already I get this:
/rd/bin/enablelp17[3]: [is: not found.


For the vsifax server script I used the one from Clay. Here it is:

#!/usr/bin/sh


VSIFAX=/opt/vsifax3
PATH=${PATH}:/usr/bin:/usr/sbin:${VSIFAX}/bin
export VSIFAX PATH

STAT=0
vfxstat -r | grep -q "is running"
VSAT=$?
if [ ${VSTAT} -ne 0 ]
then
vfxsched start
STAT=$?
fi
exit ${STAT}

When I run that script I get this result:
/rd/bin/vsifaxchecker[11]: test: Specify a parameter with this command.

So I either have not entered them in correctly, or am not running the script right, or something.

I need more help!

Thanks,

Troy
I don't think I'm in Kansas anymore.
A. Clay Stephenson
Acclaimed Contributor

Re: Script help - Vsifax

Hi Troy,

In the case of the Vsifax script, the VSIFAX env var was set to my location; yours may be different.

I think your other problem is related to the if syntax. There must be at least one space after the '[' and at least one space before the ']'.

Hope this helps, Clay
If it ain't broke, I can fix that.
Joseph C. Denman
Honored Contributor

Re: Script help - Vsifax

Your vsifax script problem is this:

The error you recieved means your test failed due to unknown variable.

The line above your test needs to be changed to VSTAT=$? verses VSAT=$?

...jcd...
If I had only read the instructions first??
Joseph C. Denman
Honored Contributor

Re: Script help - Vsifax

In your printer script???

I think you are grabbing the wrong variable. Plus make sure your have your PATH setup correctly.

I am fairly confident the it should be awk /lp17/{print $5}/

...jcd...

...jcd...
If I had only read the instructions first??
James R. Ferguson
Acclaimed Contributor
Solution

Re: Script help - Vsifax

Hi Troy:

My apologies, this should be better:

if [ "`lpstat -p|awk '$2=="myprinter" {print $3}'`" = disabled ]

...JRF...
A. Clay Stephenson
Acclaimed Contributor

Re: Script help - Vsifax

Good call Joseph; it's my advanced one-finger typing technique again.

Troy: One thing that I would suggest is that you get these scripts working perfectly from an interactive shell before you try them under cron. Cron's enviroment is very sparse so after you get them working as expected from an interactive shell you then only have to make sure that your have defined and exported PATH and any other variables.

Clay
If it ain't broke, I can fix that.
Shar Hunter
Frequent Advisor

Re: Script help - Vsifax

10-4,

Thanks for your responses, I will implement the suggestions right now.

Troy

I don't think I'm in Kansas anymore.
Shar Hunter
Frequent Advisor

Re: Script help - Vsifax

I made the changes to the path, as suggested. And used that correction to the printer script. Both are now working correctly, I tested them out. And I have them in place in crontab.

Thanks a lot.

Troy
I don't think I'm in Kansas anymore.
Nisar Ahmad
Regular Advisor

Re: Script help - Vsifax

Hi James

What UNIX95 and -C means in the cripts.

Thanks

Nisar Ahmad
Fred Martin_1
Valued Contributor

Re: Script help - Vsifax

The script attached is what I use.

My fax device name is "fax1" you'll need to change it. The script as written sends email to "watchdog" so change that too. Also my install directory is /opt/vsifax3, change it to be appropriate for your install.

It uses a couple of standard VSIFax utilities to try to determine if the server is up and status is good. Hope this helps.

I run it in root cron, every hour or so.

Also see the VSIFax website about purging on a regular basis, otherwise file systems get full.
fmartin@applicatorssales.com