- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: script help req.
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
Forums
Discussions
Discussions
Discussions
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
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
06-16-2010 03:15 AM
06-16-2010 03:15 AM
red
blue
green
I am looking for a script which looks contents of log and incase any entry is missing it will put into another log.
FILE=`cat cl`
for i in `$FILE`
do
if [ "$i" = "red" ] || [ "$i" = "blue" ] || [ "$i" = "green" ]
then
echo ""
else
echo $i > moni.log
fi
done
This SCript is not working.. Pls help
Solved! Go to Solution.
- Tags:
- scripting
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-16-2010 03:59 AM
06-16-2010 03:59 AM
Re: script help req.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-16-2010 04:36 AM
06-16-2010 04:36 AM
SolutionYour script is running infinitely.
Instead of:
# for i in `$FILE`
...you want:
# for i in "$FILE"
That is, you don't want back-ticks to cause the shell to execute.
The use of back-ticks is discouraged in POSIX compliant shells. The preferred notation for:
# FILE=`cat cl`
...would be:
# FILE=$(cat cl)
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-16-2010 06:24 PM
06-16-2010 06:24 PM
Re: script help req.
I wrote an script - which checks for process status. In case process not running should puts other log file stating process is down.
ARTIS=`ps -xef | grep java | grep ArtePryServer | awk '{print $(NF-2)}' | cut -c 54-74`
VAR=`ps -ef | grep 4445 | grep -v grep |awk '{print $NF}'`
if [ "$ARTIS" = ???? ]
then
echo "ARTIS down"
else
exit
fi
if [ "VAR" = ??? ]
then
.
.
.
Iam stuck with statement ... Pls help me..
Just incase required the real variable values are :-
ARTIS=ArtemisServer
VAR=4445
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-17-2010 04:23 AM
06-17-2010 04:23 AM
Re: script help req.
>if [ "$VAR" = ??? ]; then
What should $ARTIS and $VAR be?
If you want to check for empty you could use the obvious:
if [ "$ARTIS" = "" ]; then
Or:
if [ -z "$ARTIS" ]; then
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-18-2010 03:28 AM
06-18-2010 03:28 AM
Re: script help req.
if [ -z "$ARTIS" ]
then
echo "Artis is down"
fi
(There came no matching output from the ps command.)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-08-2010 06:24 AM
07-08-2010 06:24 AM
Re: script help req.
Any possibility to avoid this 'return 1' error.
#/usr/bin/sh
export PIDWEB=`ps -ef |grep 4444|grep start |grep -v grep|awk '{print $NF}'`
if [ -z "$PIDWEB" ]
then
echo "down" > /var/opt/admin/javanode.log
else
echo "up" > /tmp/javanode.log
echo "" > /var/opt/admin/javanode.log
fi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-08-2010 06:32 AM
07-08-2010 06:32 AM
Re: script help req.
> I have created script as below. Some times shell give 'return 1' Error, Although process up and running fine.
You aren't testing the return code of anything in the script you have shown.
Be aware that 'grep'ing for a process needs to be very explicit. You can find or miss matches with ease.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-08-2010 06:45 AM
07-08-2010 06:45 AM
Re: script help req.
I would add, that instead of doing:
# export PIDWEB=`ps -ef |grep 4444|grep start |grep -v grep|awk '{print $NF}'`
...and you know the name of the process in question, do something like this:
# PIDWEB=$(UNIX95= ps -C syslogd -opid= -oargs=)
This example assumes that the process you want to verify is the 'syslogd' daemon. If it's running, the 'PIDWEB' variable would contain something like:
756 /usr/sbin/syslogd -N -D -v
You can examine the manpages for 'ps' to see the various pieces of data that you can collect. Here, I chose to capture the pid and the arguments used to start 'syslogd'.
Using the XPG4 (UNIX95) behavior for 'ps' allows you to specifically select a process by name ('-C') and to explicitly choose the data you want returned. Do *not* set 'UNIX95' for other than the duration of the command line. That's what the 'UNIX95= ps ...' notation does. There is no semicolon following the "=", only whitespace.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-08-2010 06:49 AM
07-08-2010 06:49 AM
Re: script help req.
Is there any way I can suppress/avoid this return value within the script..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-08-2010 06:57 AM
07-08-2010 06:57 AM
Re: script help req.
> This return code is creating one alert for OPS team. Is there any way I can suppress/avoid this return value within the script..
Other than the return code of the last command executed, your script isn't returning anything other than the success or failure of the last command executed. I don't think you are showing everything!
Regards!
...JRF...