<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: run script in HPUX in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/run-script-in-hpux/m-p/4831497#M641653</link>
    <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;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&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;#!/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 " "&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;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:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;#!/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 " "&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 19 Jul 2011 07:41:50 GMT</pubDate>
    <dc:creator>Duncan Edmonstone</dc:creator>
    <dc:date>2011-07-19T07:41:50Z</dc:date>
    <item>
      <title>run script in HPUX</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/run-script-in-hpux/m-p/4831417#M641652</link>
      <description>&lt;P&gt;Hi Expert,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please advice me how to execute this script in hpux 11.31 ?&lt;/P&gt;&lt;P&gt;I tried to vi and paste this script, but it won't and got some minor error&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;!/bin/sh&lt;BR /&gt;echo " "&lt;BR /&gt;print " We are going to calculate the physical &lt;STRONG&gt;memory &lt;/STRONG&gt;and the available &lt;STRONG&gt;memory &lt;/STRONG&gt;in this HPUX System."&lt;BR /&gt;typeset -i mem=$(grep Physical /var/adm/syslog/syslog.log | awk '{print $7}')&lt;BR /&gt;print $(hostname) has $mem bytes &lt;STRONG&gt;memory &lt;/STRONG&gt;.+- $(( $mem /1024 )) mb&lt;BR /&gt;echo " "&lt;BR /&gt;print " This is the available &lt;STRONG&gt;memory &lt;/STRONG&gt;."&lt;BR /&gt;typeset -i mem1=$(grep Physical /var/adm/syslog/syslog.log | awk '{print $13}')&lt;BR /&gt;print $(hostname) has $mem1 bytes of available &lt;STRONG&gt;memory &lt;/STRONG&gt;.+- $(( $mem1 /1024 )) mb&lt;BR /&gt;echo " "&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Tue, 19 Jul 2011 06:57:53 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/run-script-in-hpux/m-p/4831417#M641652</guid>
      <dc:creator>Naj</dc:creator>
      <dc:date>2011-07-19T06:57:53Z</dc:date>
    </item>
    <item>
      <title>Re: run script in HPUX</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/run-script-in-hpux/m-p/4831497#M641653</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;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&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;#!/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 " "&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;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:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;#!/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 " "&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 19 Jul 2011 07:41:50 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/run-script-in-hpux/m-p/4831497#M641653</guid>
      <dc:creator>Duncan Edmonstone</dc:creator>
      <dc:date>2011-07-19T07:41:50Z</dc:date>
    </item>
    <item>
      <title>Re: run script in HPUX</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/run-script-in-hpux/m-p/4831975#M641654</link>
      <description>&lt;P&gt;Hi:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does an error message like, "...line 1: !bin/sh: No such file or directory" suggest anything?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Shell scripts should begin with a "she-bang" line also known as the interpreter line.&amp;nbsp; The special sequence "#!" tells which interpreter program to run.&amp;nbsp; In HP-UX, '/bin/sh' is the so-called POSIX shell used by HP ('/usr/bin/sh' or '/sbin/sh' for root).&amp;nbsp; In many Linux systems, '/bin/sh' is symlinked to the Bash shell.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In you case, the missing hash mark meant that no she-bang was recognized.&amp;nbsp; 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.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;...JRF...&lt;/P&gt;</description>
      <pubDate>Tue, 19 Jul 2011 11:55:38 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/run-script-in-hpux/m-p/4831975#M641654</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2011-07-19T11:55:38Z</dc:date>
    </item>
    <item>
      <title>Re: run script in HPUX</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/run-script-in-hpux/m-p/4832959#M641655</link>
      <description>&lt;P&gt;Thanks for the answering.. but im newbie in script. could you confirm me below are true step to execute?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. #pwd&lt;/P&gt;&lt;P&gt;/root/home/root/myfolder/&lt;/P&gt;&lt;P&gt;2. #touch checkmem.sh&lt;/P&gt;&lt;P&gt;3.#vi checkmem.sh&lt;/P&gt;&lt;P&gt;4. paste script and save file&lt;/P&gt;&lt;P&gt;5.#pwd ; ls&lt;/P&gt;&lt;P&gt;root/home/root/myfolder/﻿&lt;/P&gt;&lt;P&gt;checkmem.sh&lt;/P&gt;&lt;P&gt;6.#./checkmem.sh&lt;/P&gt;&lt;P&gt;output&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is it true?&lt;/P&gt;&lt;P&gt;Please confirm me&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;BR&lt;/P&gt;&lt;P&gt;Naj&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Jul 2011 03:09:27 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/run-script-in-hpux/m-p/4832959#M641655</guid>
      <dc:creator>Naj</dc:creator>
      <dc:date>2011-07-20T03:09:27Z</dc:date>
    </item>
    <item>
      <title>Re: run script in HPUX</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/run-script-in-hpux/m-p/4833235#M641656</link>
      <description>&lt;P&gt;&amp;gt;2. #touch checkmem.sh&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;No need for this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;3.#vi checkmem.sh&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;gt;checkmem.sh&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;chmod a+x checkmem.sh﻿&amp;nbsp; # make it executable&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;6.#./checkmem.sh&lt;/P&gt;&lt;P&gt;output&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;gt;Is it true?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Assuming you have a "#!" with your shell on the first line, yes.&lt;/P&gt;&lt;P&gt;You can also syntax check your script with:&lt;/P&gt;&lt;P&gt;sh -n checkmem.sh﻿&lt;/P&gt;</description>
      <pubDate>Wed, 20 Jul 2011 07:30:33 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/run-script-in-hpux/m-p/4833235#M641656</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2011-07-20T07:30:33Z</dc:date>
    </item>
  </channel>
</rss>

