- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- run script in HPUX
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
07-18-2011 11:57 PM
07-18-2011 11:57 PM
Hi Expert,
Please advice me how to execute this script in hpux 11.31 ?
I tried to vi and paste this script, but it won't and got some minor error
!/bin/sh
echo " "
print " We are going to calculate the physical memory and the available memory in this HPUX System."
typeset -i mem=$(grep Physical /var/adm/syslog/syslog.log | awk '{print $7}')
print $(hostname) has $mem bytes memory .+- $(( $mem /1024 )) mb
echo " "
print " This is the available memory ."
typeset -i mem1=$(grep Physical /var/adm/syslog/syslog.log | awk '{print $13}')
print $(hostname) has $mem1 bytes of available memory .+- $(( $mem1 /1024 )) mb
echo " "
Thanks
____________________________________________
:: Really appreciate if you could assign some points.
:: Don't know how to assign point? Click the KUDOS! star!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-19-2011 12:41 AM
07-19-2011 12:41 AM
Re: run script in HPUX
Syntactically, the only major problem with this script is a missing "#" symbol at the start of the first line - cut and paste the following and it should run fine. Oh and also those values will be in KB, not Bytes
#!/bin/sh echo " " print " We are going to calculate the physical memory and the available memory in this HPUX System." typeset -i mem=$(grep Physical /var/adm/syslog/syslog.log | awk '{print $7}') print $(hostname) has $mem KB memory .+- $(( $mem /1024 )) MB echo " " print " This is the available memory ." typeset -i mem1=$(grep Physical /var/adm/syslog/syslog.log | awk '{print $13}') print $(hostname) has $mem1 KB of available memory .+- $(( $mem1 /1024 )) MB echo " "
Of course that doesn't mean this is a good script! As a method for determining the amount of memory on a system just looking in syslog.log is not by any means reliable, as this log can be rotated or truncated meaning the information from boot time is no longer available.
And of course the value you calculate for "available memory" is meaningless, as it just tells you how much memory was available when the system booted, not how much is available (presumably you want to know "free" memory?) when the script is run. A quick and dirty, but more reliable script might be something like this:
#!/bin/sh echo " " print " We are going to calculate the physical memory and the available memory in this HPUX System." mem=$(machinfo | grep ^Memory: | awk '{ print $2 }') print $(hostname) $mem MB Physical Memory echo " " print " This is the available (free) memory ." typeset -i free_pages=$(vmstat | tail -1 | awk '{ print $5 }') typeset -i page_size=$(kctune -P current base_pagesize | cut -f 2) (( mem1 = ${free_pages} * ${page_size} )) print $(hostname) has $mem1 bytes of available memory .+- $(( $mem1 /1024 )) mb echo " "
I am an HPE Employee

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-19-2011 04:55 AM
07-19-2011 04:55 AM
Re: run script in HPUX
Hi:
Does an error message like, "...line 1: !bin/sh: No such file or directory" suggest anything?
Shell scripts should begin with a "she-bang" line also known as the interpreter line. The special sequence "#!" tells which interpreter program to run. In HP-UX, '/bin/sh' is the so-called POSIX shell used by HP ('/usr/bin/sh' or '/sbin/sh' for root). In many Linux systems, '/bin/sh' is symlinked to the Bash shell.
In you case, the missing hash mark meant that no she-bang was recognized. By default, your script was executed with the same shell interpreter as your session and was otherwise syntatically valid as a POSIX (or even 'ksh') shell.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-19-2011 08:09 PM
07-19-2011 08:09 PM
Re: run script in HPUX
Thanks for the answering.. but im newbie in script. could you confirm me below are true step to execute?
1. #pwd
/root/home/root/myfolder/
2. #touch checkmem.sh
3.#vi checkmem.sh
4. paste script and save file
5.#pwd ; ls
root/home/root/myfolder/
checkmem.sh
6.#./checkmem.sh
output
Is it true?
Please confirm me
Thanks
BR
Naj
____________________________________________
:: Really appreciate if you could assign some points.
:: Don't know how to assign point? Click the KUDOS! star!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-20-2011 12:30 AM
07-20-2011 12:30 AM
Solution>2. #touch checkmem.sh
No need for this.
3.#vi checkmem.sh
>checkmem.sh
chmod a+x checkmem.sh # make it executable
6.#./checkmem.sh
output
>Is it true?
Assuming you have a "#!" with your shell on the first line, yes.
You can also syntax check your script with:
sh -n checkmem.sh