Operating System - HP-UX
1832973 Members
2179 Online
110048 Solutions
New Discussion

Re: ftstatus command in shell script not working with cron scheduled

 
kingkhan
Occasional Advisor

ftstatus command in shell script not working with cron scheduled

ftstatus in HP-UX which outputs FaultTolerant Controllers out in SS7stacks is not working inside a shell script with scheduled cron. but the same commands gets the report while script is executed manually.
16 REPLIES 16
Torsten.
Acclaimed Contributor

Re: ftstatus command in shell script not working with cron scheduled

Do you use full pathes for each command in your script?

Hope this helps!
Regards
Torsten.

__________________________________________________
There are only 10 types of people in the world -
those who understand binary, and those who don't.

__________________________________________________
No support by private messages. Please ask the forum!

If you feel this was helpful please click the KUDOS! thumb below!   
Oviwan
Honored Contributor

Re: ftstatus command in shell script not working with cron scheduled

hey

load the user profile at the beginning of your script to setup your environment.

. /home/username/.profile

Regards
kingkhan
Occasional Advisor

Re: ftstatus command in shell script not working with cron scheduled

i am using full path to execute script in cron.
is this ok.
#!/bin/sh
./root/.profile
Torsten.
Acclaimed Contributor

Re: ftstatus command in shell script not working with cron scheduled

Again: Do you use full pathes for each command in your script?

Due to a limited environment in cron you have only a very limited PATH variable by default.
Sourcing the profile is not the best workaround here.

Hope this helps!
Regards
Torsten.

__________________________________________________
There are only 10 types of people in the world -
those who understand binary, and those who don't.

__________________________________________________
No support by private messages. Please ask the forum!

If you feel this was helpful please click the KUDOS! thumb below!   
kingkhan
Occasional Advisor

Re: ftstatus command in shell script not working with cron scheduled

00,10,20,30,40,50 * * * * /BOC_KK/new.sh
this is the line in cron and the new.sh file look like this

#!/bin/sh

df -k >>/BOC_KK/xyz.txt
ftstatus >>/BOC_KK/xyz.txt


when i am executing manually new.sh with sh new.sh it creates a file xyz.txt in /BOC_KK,but the same thing i am putting through cron it outputs xyz.txt with only df -k results.
Pete Randall
Outstanding Contributor

Re: ftstatus command in shell script not working with cron scheduled

When you manually execute this, your environment contains a fully set PATH variable, something that cron does not provide. You therefore need to provide the full path name identifying where these things are located. Something like this:

/usr/bin/df -k >>/BOC_KK/xyz.txt
/home/kingkhan/ftstatus >>/BOC_KK/xyz.txt


Pete

Pete
Torsten.
Acclaimed Contributor

Re: ftstatus command in shell script not working with cron scheduled

Modify your script!

Instead of

ftstatus

you should use

/full/path/to/ftstatus

Use "whereis ftstatus" to get the path.

Hope this helps!
Regards
Torsten.

__________________________________________________
There are only 10 types of people in the world -
those who understand binary, and those who don't.

__________________________________________________
No support by private messages. Please ask the forum!

If you feel this was helpful please click the KUDOS! thumb below!   
kingkhan
Occasional Advisor

Re: ftstatus command in shell script not working with cron scheduled

matrix:root> whereis ftstatus
ftstatus:
matrix:root>


i am getting this output
Torsten.
Acclaimed Contributor

Re: ftstatus command in shell script not working with cron scheduled

So you probably need to use "find" to find the location of this application.

Hope this helps!
Regards
Torsten.

__________________________________________________
There are only 10 types of people in the world -
those who understand binary, and those who don't.

__________________________________________________
No support by private messages. Please ask the forum!

If you feel this was helpful please click the KUDOS! thumb below!   
OldSchool
Honored Contributor

Re: ftstatus command in shell script not working with cron scheduled

at the command line, enter:

which ftstatus
-or-
whence ftstatus

they should report the full path to the app
kingkhan
Occasional Advisor

Re: ftstatus command in shell script not working with cron scheduled

when i tried find / -name ftstatus i got it in
/opt/HP-AIN/SS7/bin/ftstatus >>/BOC_KK/xyz.txt

but no improvement . still i am not getting the expected results
Dennis Handly
Acclaimed Contributor

Re: ftstatus command in shell script not working with cron scheduled

>but no improvement. still i am not getting the expected results

You'll need to explain what you got and what you want.
kingkhan
Occasional Advisor

Re: ftstatus command in shell script not working with cron scheduled

this output i am expecting from my script.
matrix:root> ftstatus
System : matrix
------------------------------------------------------------
FT_Controller(FTC) ACTIVE[OK]
DataStore ACTIVE
ss7SNMPAgent ACTIVE
SS7_Stack_1_ftc(subFTC) ACTIVE[OK]
SS7_Stack_1_TDx_1 ACTIVE
SS7_Stack_1 ACTIVE
SS7_Stack_2_ftc(subFTC) ACTIVE[OK]
SS7_Stack_2_TDx_1 ACTIVE
SS7_Stack_2 ACTIVE

-------------------------------------------
iam able to get this output one i manually execute the script,but the same thing i am not getting while the script is scheduled through cron.plz help
kingkhan
Occasional Advisor

Re: ftstatus command in shell script not working with cron scheduled

this output i am expecting from my script.
root> ftstatus
System : matrix
------------------------------------------------------------
FT_Controller(FTC) ACTIVE[OK]
DataStore ACTIVE
ss7SNMPAgent ACTIVE
SS7_Stack_1_ftc(subFTC) ACTIVE[OK]
SS7_Stack_1_TDx_1 ACTIVE
SS7_Stack_1 ACTIVE
SS7_Stack_2_ftc(subFTC) ACTIVE[OK]
SS7_Stack_2_TDx_1 ACTIVE
SS7_Stack_2 ACTIVE

-------------------------------------------
iam able to get this output one i manually execute the script,but the same thing i am not getting while the script is scheduled through cron.plz help
Dennis Handly
Acclaimed Contributor

Re: ftstatus command in shell script not working with cron scheduled

>this output i am expecting from my script.

But what are you getting?

>i manually execute the script,

Have you put absolute paths for every executable you use in your script?
Or changed PATH to include them?
Pete Randall
Outstanding Contributor

Re: ftstatus command in shell script not working with cron scheduled

Change your script so it looks EXACTLY like this:

#!/bin/sh

/usr/bin/df -k >>/BOC_KK/xyz.txt
/opt/HP-AIN/SS7/bin/ftstatus >>/BOC_KK/xyz.txt


Pete

Pete