<?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 Script help....expr command in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/script-help-expr-command/m-p/5179596#M682571</link>
    <description>I want to be able to print the disk space usage out from a script.  The following is my script:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;#&lt;BR /&gt;#echo "Which volume group? \c"&lt;BR /&gt;#read ANS&lt;BR /&gt;&lt;BR /&gt;HOMEDIR=/home/smid/scripts&lt;BR /&gt;BDFMEGS=$HOMEDIR/bdfm&lt;BR /&gt;if [ ! -x $BDFMEGS ]&lt;BR /&gt;then&lt;BR /&gt;echo "ERROR: $BDFMEGS does not exist!"&lt;BR /&gt;exit 1&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;SUM=0&lt;BR /&gt;&lt;BR /&gt;# Cut out the first line from output&lt;BR /&gt;for i in `/usr/local/bin/sudo strings /etc/lvmtab |grep dev|grep -v dsk|grep -v vg00`; do&lt;BR /&gt;var=`$BDFMEGS|grep $i | grep -v : |awk '{print $3}'`&lt;BR /&gt;SUM=`expr $SUM + $var`&lt;BR /&gt;echo "`hostname`: $i Total Space Used (MB) = $SUM"&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;I am almost there but the expr is not working out.  Here is what I get for the output when using set -x:&lt;BR /&gt;&lt;BR /&gt;$ ./disk_used.sh&lt;BR /&gt;+ HOMEDIR=/home/smid/scripts&lt;BR /&gt;+ BDFMEGS=/home/smid/scripts/bdfm&lt;BR /&gt;+ [ ! -x /home/smid/scripts/bdfm ]&lt;BR /&gt;+ SUM=0&lt;BR /&gt;+ /usr/local/bin/sudo strings /etc/lvmtab&lt;BR /&gt;+ grep dev&lt;BR /&gt;+ grep -v vg00&lt;BR /&gt;+ grep -v dsk&lt;BR /&gt;+ + /home/smid/scripts/bdfm&lt;BR /&gt;+ grep /dev/vgvnadmin&lt;BR /&gt;+ grep -v :&lt;BR /&gt;+ awk {print $3}&lt;BR /&gt;var=5886&lt;BR /&gt;394&lt;BR /&gt;332&lt;BR /&gt;7382&lt;BR /&gt;6854&lt;BR /&gt;9099&lt;BR /&gt;29&lt;BR /&gt;+ + expr 0 + 5886 394 332 7382 6854 9099 29&lt;BR /&gt;expr: Syntax error&lt;BR /&gt;&lt;BR /&gt;So it isn't using +'s between each $var.  &lt;BR /&gt;&lt;BR /&gt;Thanks for the help,&lt;BR /&gt;S</description>
    <pubDate>Fri, 05 Jun 2009 10:30:36 GMT</pubDate>
    <dc:creator>dev44</dc:creator>
    <dc:date>2009-06-05T10:30:36Z</dc:date>
    <item>
      <title>Script help....expr command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-help-expr-command/m-p/5179596#M682571</link>
      <description>I want to be able to print the disk space usage out from a script.  The following is my script:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;#&lt;BR /&gt;#echo "Which volume group? \c"&lt;BR /&gt;#read ANS&lt;BR /&gt;&lt;BR /&gt;HOMEDIR=/home/smid/scripts&lt;BR /&gt;BDFMEGS=$HOMEDIR/bdfm&lt;BR /&gt;if [ ! -x $BDFMEGS ]&lt;BR /&gt;then&lt;BR /&gt;echo "ERROR: $BDFMEGS does not exist!"&lt;BR /&gt;exit 1&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;SUM=0&lt;BR /&gt;&lt;BR /&gt;# Cut out the first line from output&lt;BR /&gt;for i in `/usr/local/bin/sudo strings /etc/lvmtab |grep dev|grep -v dsk|grep -v vg00`; do&lt;BR /&gt;var=`$BDFMEGS|grep $i | grep -v : |awk '{print $3}'`&lt;BR /&gt;SUM=`expr $SUM + $var`&lt;BR /&gt;echo "`hostname`: $i Total Space Used (MB) = $SUM"&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;I am almost there but the expr is not working out.  Here is what I get for the output when using set -x:&lt;BR /&gt;&lt;BR /&gt;$ ./disk_used.sh&lt;BR /&gt;+ HOMEDIR=/home/smid/scripts&lt;BR /&gt;+ BDFMEGS=/home/smid/scripts/bdfm&lt;BR /&gt;+ [ ! -x /home/smid/scripts/bdfm ]&lt;BR /&gt;+ SUM=0&lt;BR /&gt;+ /usr/local/bin/sudo strings /etc/lvmtab&lt;BR /&gt;+ grep dev&lt;BR /&gt;+ grep -v vg00&lt;BR /&gt;+ grep -v dsk&lt;BR /&gt;+ + /home/smid/scripts/bdfm&lt;BR /&gt;+ grep /dev/vgvnadmin&lt;BR /&gt;+ grep -v :&lt;BR /&gt;+ awk {print $3}&lt;BR /&gt;var=5886&lt;BR /&gt;394&lt;BR /&gt;332&lt;BR /&gt;7382&lt;BR /&gt;6854&lt;BR /&gt;9099&lt;BR /&gt;29&lt;BR /&gt;+ + expr 0 + 5886 394 332 7382 6854 9099 29&lt;BR /&gt;expr: Syntax error&lt;BR /&gt;&lt;BR /&gt;So it isn't using +'s between each $var.  &lt;BR /&gt;&lt;BR /&gt;Thanks for the help,&lt;BR /&gt;S</description>
      <pubDate>Fri, 05 Jun 2009 10:30:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-help-expr-command/m-p/5179596#M682571</guid>
      <dc:creator>dev44</dc:creator>
      <dc:date>2009-06-05T10:30:36Z</dc:date>
    </item>
    <item>
      <title>Re: Script help....expr command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-help-expr-command/m-p/5179597#M682572</link>
      <description>Hello,&lt;BR /&gt;&lt;BR /&gt;Try this instead&lt;BR /&gt;&lt;BR /&gt;&amp;gt;&amp;gt;SUM=`expr $SUM + $var`&lt;BR /&gt;&lt;BR /&gt;SUM= $((SUM + var))&lt;BR /&gt;&lt;BR /&gt;Rgds&lt;BR /&gt;Johnson</description>
      <pubDate>Fri, 05 Jun 2009 10:56:24 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-help-expr-command/m-p/5179597#M682572</guid>
      <dc:creator>johnsonpk</dc:creator>
      <dc:date>2009-06-05T10:56:24Z</dc:date>
    </item>
    <item>
      <title>Re: Script help....expr command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-help-expr-command/m-p/5179598#M682573</link>
      <description>Figured it out.  Thanks.</description>
      <pubDate>Fri, 05 Jun 2009 11:12:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-help-expr-command/m-p/5179598#M682573</guid>
      <dc:creator>dev44</dc:creator>
      <dc:date>2009-06-05T11:12:08Z</dc:date>
    </item>
    <item>
      <title>Re: Script help....expr command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-help-expr-command/m-p/5179599#M682574</link>
      <description>&lt;!--!*#--&gt;Hi:&lt;BR /&gt;&lt;BR /&gt;The syntax of the 'expr' statement is OK.  Your trace suggests that your 'var' variable isn't a simple integer but some string of integers.  Consider:&lt;BR /&gt;&lt;BR /&gt;# cat ./mybad&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;set -x&lt;BR /&gt;SUM=0&lt;BR /&gt;for var in "1 2 3 4 5"&lt;BR /&gt;do&lt;BR /&gt;    SUM=`expr $SUM + $var`&lt;BR /&gt;    echo $SUM&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;# ./mybad&lt;BR /&gt;+ SUM=0&lt;BR /&gt;+ + expr 0 + 1 2 3 4 5&lt;BR /&gt;expr: Syntax error&lt;BR /&gt;&lt;BR /&gt;SUM=&lt;BR /&gt;+ echo&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Fri, 05 Jun 2009 11:19:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-help-expr-command/m-p/5179599#M682574</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2009-06-05T11:19:35Z</dc:date>
    </item>
    <item>
      <title>Re: Script help....expr command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-help-expr-command/m-p/5179600#M682575</link>
      <description>You may want to toss expr(1) unless you are using it for substrings.&lt;BR /&gt;This: SUM=`expr $SUM + $var`&lt;BR /&gt;can be done as: (( SUM += var ))&lt;BR /&gt;</description>
      <pubDate>Fri, 05 Jun 2009 11:34:57 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-help-expr-command/m-p/5179600#M682575</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2009-06-05T11:34:57Z</dc:date>
    </item>
  </channel>
</rss>

