- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Scripting Question
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-12-2005 01:31 PM
тАО10-12-2005 01:31 PM
Scripting Question
if [ $BINDIR/schedule $nodename = "A" ]
then
echo "Message 1"
exit 1
fi
if [ $BINDIR/schedule $nodename = "B" ]
then
echo "Message 2"
exit 0
fi
if [ $BINDIR/schedule $nodename = "C" ]
then
echo "Message 3"
exit 1
fi
sendsms "Message 4" "TT0001" "MYServer"
"schedule" is another script called to check a textfile for values.
Based on the code fragment, lets assuming that "schedule $nodename" is suppose to return "A". Is there any chance that the "sendsms" is run before the "schedule" could return the value? (esp in the scenario that the main script is triggered many times simultaneously)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-12-2005 01:37 PM
тАО10-12-2005 01:37 PM
Re: Scripting Question
It would appear that 'schedule' returned something other then A, B, or C under those high contention situation. Maybe it failed outright?.
I would capture the return value in a variable and include that in the senssms text, as well as the nodename that triggered it.
fwiw,
Hein.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-12-2005 02:03 PM
тАО10-12-2005 02:03 PM
Re: Scripting Question
echo "Message #" is written to a test file.
i.e. echo "Message #" >> script.log
and for the last part of the script where the sendsms is run, I have something like this:
echo "sendsms Message 4 TT0001 MYServer" >> script.log
The funny thing is when I look back at the log.
I found the follow text in the follow order:
sendsms Message 4 TT0001 MYServer
Message #
In the normal situation, "Message #" should be returned and the script should end and "sendsms Message 4 TT0001 MYServer" should not appear.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-12-2005 02:40 PM
тАО10-12-2005 02:40 PM
Re: Scripting Question
if you can tell what you are really after, i.e., what you want this script to do, maybe the help gets better.
UNIX because I majored in cryptology...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-12-2005 02:48 PM
тАО10-12-2005 02:48 PM
Re: Scripting Question
if [ $BINDIR/schedule $nodename = "A" ]
then
echo "Message 1"
exitFLAG=1
fi
if [ $BINDIR/schedule $nodename = "B" ]
then
echo "Message 2"
exitFLAG=0
fi
if [ $BINDIR/schedule $nodename = "C" ]
then
echo "Message 3"
exitFLAG=1
fi
sendsms "Message 4" "TT0001" "MYServer"
exit $exitFLAG
UNIX because I majored in cryptology...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-12-2005 03:37 PM
тАО10-12-2005 03:37 PM
Re: Scripting Question
RESULT=$($BINDIR/schedule $nodename)
case $RESULT in
A) echo "Message 1"
exit 1
B) echo "Message 2"
exit 0
C) echo "Message 3"
exit 1
*) sendsms "Message 4" "TT0001" "MYServer"
The case statement is doing the comparison and allows for multiple choices, longer strings, use of regular expressions like *, and so on.
Bill Hassell, sysadmin
- Tags:
- case
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-12-2005 03:39 PM
тАО10-12-2005 03:39 PM
Re: Scripting Question
if [ $BINDIR/schedule $nodename = "A" ]
then
echo "Message 1" >> script.log
exit 1
fi
if [ $BINDIR/schedule $nodename = "B" ]
then
echo "Message 2" >> script.log
exit 0
fi
if [ $BINDIR/schedule $nodename = "C" ]
then
echo "Message 3" >> script.log
exit 1
fi
sendsms "Message 4" "TT0001" "MYServer"
echo "sendsms Message 4 TT0001 MYServer" >> script.log
The "if" conditions above is to check if there is a scheduled downtime. If yes, depending of what type of downtime, it will write it to the log file and then exit.
In the case where there is no downtime recorded, all conditions should be invalid and a sms would be sent out and the message will be recorded in the same log file.
However, this is what is seen on the script.log:
sendsms Message 4 TT0001 MYServer
Message 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-12-2005 07:57 PM
тАО10-12-2005 07:57 PM
Re: Scripting Question
downtime_type=$($BINDIR/schedule $nodename)
if [ "${downtime_type}" = "A" ]
then
echo "Message 1" >> script.log
exit 1
elif [ "${downtime_type}" = "B" ]
then
echo "Message 2" >> script.log
exit 0
elif [ "${downtime_type}" = "C" ]
then
echo "Message 3" >> script.log
exit 1
else
sendsms "Message 4" "TT0001" "MYServer"
echo "sendsms Message 4 TT0001 MYServer" >> script.log
fi
More than this, use Bill's case method. It is neat.
hth.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-12-2005 11:29 PM
тАО10-12-2005 11:29 PM
Re: Scripting Question
Bill'ds case statement solution reminded me of an onder remark I forgot to make explicit...
What if the $BINDIR/schedule result changes exactly between two steps. That is, while it was testing for A is was C, and when it tested for B is had already become A, but neither triggered a match.
So in a concurrent environment you HAVE to first grab the result into a variable, then test it. It is not only the more efficient way to go about business, it is the only right way to do the job.
Regards,
Hein.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-13-2005 01:42 AM
тАО10-13-2005 01:42 AM
Re: Scripting Question
Could it be that what you are seeing is yesterdays run of the script which sent the sms message and todays which generated message 2
I also agree that your best bet is to put it into a case statement.
H