- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- shell script help
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
03-10-2003 06:47 PM
03-10-2003 06:47 PM
shell script help
This is the output from the omnistat
SessionID Type Status User
===============================================================================
2003/03/11-18 Backup Mount Request root.sys@abc.net
2003/03/11-20 Backup In Progress root.sys@abc.net
This is my script.
#!/usr/bin/sh
OUTPUT=/tmp/abort_backup.rpt
if [ -f $OUTPUT ]
then
rm $OUTPUT
fi
touch $OUTPUT
CONDITION=$(/opt/omni/bin/omnistat | grep "No currently running sessions.")
if [ -n "$CONDITION" ]
then
echo "Not Backup is running"
else
PATTERN_TEXT="backup"
SESSION=`/opt/omni/bin/omnistat | grep -i "$PATTERN_TEXT" | awk '{print $1}'`
DATE=`date`
echo $SESSION > /tmp/abort_list
echo "$SESSION was aborted by script on $DATE"
#/opt/omni/bin/omniabort -ses $SESSION
rm /tmp/abort_list
fi
My problem is sometimes there might be more than 1 sessions running and I want to abort all of them.
When I pipe the $SESSION to a file, all sessions number will be put into one line.
For example in the abort_list file the session number will be look like this.
2003/1/1223-23 2003/2/1223-24
But I would like to have a new line for 2003/2/1223-24 so that I can abort all the session one by one.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-10-2003 07:04 PM
03-10-2003 07:04 PM
Re: shell script help
You could do a 'for' loop on the contents of your $SESSION variable. Something like this:
PATTERN_TEXT="backup"
SESSION=`/opt/omni/bin/omnistat | grep -i "$PATTERN_TEXT" | awk '{print $1}'`
for SESS in $SESSION;
do
DATE=`date`
echo $SESS > /tmp/abort_list
echo "$SESS was aborted by script on $DATE"
#/opt/omni/bin/omniabort -ses $SESS
rm /tmp/abort_list
fi
done
JP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-10-2003 07:04 PM
03-10-2003 07:04 PM
Re: shell script help
for i in `omnistat | sed -n '3,$p' | cut -c1-14`
do
omniabort -session $i
done
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-10-2003 07:05 PM
03-10-2003 07:05 PM
Re: shell script help
2003/1/1223-23 2003/1/1223-23
cat file1 | while read a
do
${echo $a | awk '{ print $2 }'
done > file2
This will give you file1 with :
2003/1/1223-23
...and file2 with
2003/1/1223-23
Now just append them both into file3
cat file1 > file3
cat file2 >> file3
...for the following:
2003/1/1223-23
2003/1/1223-23
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-11-2003 12:52 AM
03-11-2003 12:52 AM
Re: shell script help
Just a few thoughts:
You don't need to check a file's existence before removing it, just use the "rm -f filename" syntax to surpress any warning messages.
Your OUTPUT file never seems to be used either.
To save running omnistat more than once, you could wrap it in a loop and case construct:
/opt/omni/bin/omnistat | while read line ; do
case $line
in
"No currently running sessions")
echo "Backup is not running"
;;
*Backup*)
echo $line | awk '{print $1}' | read SESSION
/opt/omni/bin/omniabort -ses $SESSION
echo $SESSION was aborted by script on `date`
;;
esac
done
rgds, Robin