<?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: Status of Previous command ? in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/status-of-previous-command/m-p/3516394#M219097</link>
    <description>Thanks Stephenson , for further explanations. echo $? is applicable for any command. &lt;BR /&gt;&lt;BR /&gt;ex: # ps -ef | grep pmon&lt;BR /&gt;     #  userdel abc&lt;BR /&gt;&lt;BR /&gt;and thanks for showing the built in test for file testing , if exists , writable or executable etc.&lt;BR /&gt;&lt;BR /&gt;Thanks so much. Thanks Geof and all who replied.&lt;BR /&gt;&lt;BR /&gt;Points Assigned **&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Veri.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;     &lt;BR /&gt;</description>
    <pubDate>Fri, 01 Apr 2005 13:47:12 GMT</pubDate>
    <dc:creator>rveri</dc:creator>
    <dc:date>2005-04-01T13:47:12Z</dc:date>
    <item>
      <title>Status of Previous command ?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/status-of-previous-command/m-p/3516386#M219089</link>
      <description>How to see if the prevous command was successful or not.&lt;BR /&gt;&lt;BR /&gt;ex: &lt;BR /&gt;&lt;BR /&gt;$ ls -l abc&lt;BR /&gt;abc not found&lt;BR /&gt;$&lt;BR /&gt;&lt;BR /&gt;but abc not exit. So its unsuccesful.&lt;BR /&gt;&lt;BR /&gt;Hence how to find out that , last command [ ls -l abc ] wasn't successful. Any command is there.&lt;BR /&gt;&lt;BR /&gt;Thanks ,&lt;BR /&gt;Regards,&lt;BR /&gt;Veri.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 01 Apr 2005 12:44:40 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/status-of-previous-command/m-p/3516386#M219089</guid>
      <dc:creator>rveri</dc:creator>
      <dc:date>2005-04-01T12:44:40Z</dc:date>
    </item>
    <item>
      <title>Re: Status of Previous command ?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/status-of-previous-command/m-p/3516387#M219090</link>
      <description>echo $?&lt;BR /&gt;&lt;BR /&gt;man sh-posix</description>
      <pubDate>Fri, 01 Apr 2005 12:48:15 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/status-of-previous-command/m-p/3516387#M219090</guid>
      <dc:creator>RAC_1</dc:creator>
      <dc:date>2005-04-01T12:48:15Z</dc:date>
    </item>
    <item>
      <title>Re: Status of Previous command ?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/status-of-previous-command/m-p/3516388#M219091</link>
      <description>ls -l abc&lt;BR /&gt;STAT=${?}&lt;BR /&gt;if [[ ${STAT} -eq 0 ]]&lt;BR /&gt;then&lt;BR /&gt;  echo "Command Ok"&lt;BR /&gt;else&lt;BR /&gt;  echo "Failed; Status = ${STAT}"&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;${?} is the return value of the last executed comand. It's a good idea to capture it in another variable because the next comand will alter ${?}. By convention, 0 indicates a good result although there are a few exceptions.&lt;BR /&gt;</description>
      <pubDate>Fri, 01 Apr 2005 12:48:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/status-of-previous-command/m-p/3516388#M219091</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2005-04-01T12:48:19Z</dc:date>
    </item>
    <item>
      <title>Re: Status of Previous command ?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/status-of-previous-command/m-p/3516389#M219092</link>
      <description>ls -l abc &lt;BR /&gt;if [ $? -ne 0 ]; then &lt;BR /&gt;echo abc not found&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;or,&lt;BR /&gt;ls -l abc||echo abc not found.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 01 Apr 2005 12:53:31 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/status-of-previous-command/m-p/3516389#M219092</guid>
      <dc:creator>TwoProc</dc:creator>
      <dc:date>2005-04-01T12:53:31Z</dc:date>
    </item>
    <item>
      <title>Re: Status of Previous command ?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/status-of-previous-command/m-p/3516390#M219093</link>
      <description>And another way:&lt;BR /&gt;&lt;BR /&gt;for i in `sed -n '/^LV/p' $CNTL |awk -F\" '{print $4}'`&lt;BR /&gt;do&lt;BR /&gt;mount |grep $i &amp;gt;/dev/null&lt;BR /&gt;&lt;BR /&gt;if [ $? -ne 0 ]&lt;BR /&gt;then&lt;BR /&gt;        echo "$i is not mounted!!!"&lt;BR /&gt;fi&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Rgds...Geoff</description>
      <pubDate>Fri, 01 Apr 2005 12:54:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/status-of-previous-command/m-p/3516390#M219093</guid>
      <dc:creator>Geoff Wild</dc:creator>
      <dc:date>2005-04-01T12:54:59Z</dc:date>
    </item>
    <item>
      <title>Re: Status of Previous command ?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/status-of-previous-command/m-p/3516391#M219094</link>
      <description>Hi , Anil, Clay , John and Geof ,&lt;BR /&gt;&lt;BR /&gt;Thanks for all the quick reply. &lt;BR /&gt;&lt;BR /&gt;echo $? and the next two script works fine.&lt;BR /&gt;&lt;BR /&gt;But I could not understand the last script by Geof. &lt;BR /&gt;&lt;BR /&gt;Thanks to all,&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Veri.&lt;BR /&gt;---------&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 01 Apr 2005 13:09:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/status-of-previous-command/m-p/3516391#M219094</guid>
      <dc:creator>rveri</dc:creator>
      <dc:date>2005-04-01T13:09:49Z</dc:date>
    </item>
    <item>
      <title>Re: Status of Previous command ?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/status-of-previous-command/m-p/3516392#M219095</link>
      <description>I should also add that for this particular task, calling ls and checking the result is a bit cumbersome. The better approach is to use the shell's builtin test command using the [[ ]]'s (double brackets). This way you don't have stderr's outpiut cluttering up your terminal -- although you can redirect stderr to get rid of that.&lt;BR /&gt;&lt;BR /&gt;FNAME="abc"&lt;BR /&gt;if [[ -e ${FNAME} ]]&lt;BR /&gt;  then&lt;BR /&gt;    echo "File ${FNAME}" exists"&lt;BR /&gt;  else&lt;BR /&gt;    echo "File ${FNAME} not found"&lt;BR /&gt;  fi&lt;BR /&gt;&lt;BR /&gt;You can also do things like:&lt;BR /&gt;if [[ -w ${FNAME} &amp;amp;&amp;amp; -x ${FNAME} ]]&lt;BR /&gt;  then&lt;BR /&gt;    echo "File ${FNAME} exists and is writable and executable"&lt;BR /&gt;  fi&lt;BR /&gt;</description>
      <pubDate>Fri, 01 Apr 2005 13:18:26 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/status-of-previous-command/m-p/3516392#M219095</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2005-04-01T13:18:26Z</dc:date>
    </item>
    <item>
      <title>Re: Status of Previous command ?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/status-of-previous-command/m-p/3516393#M219096</link>
      <description>Okay:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;#!/bin/sh&lt;BR /&gt;#&lt;BR /&gt;# script to check all file systems are mounted&lt;BR /&gt;# gwild&lt;BR /&gt;&lt;BR /&gt;CNTL=/etc/cmcluster/IPRDBCI/iprdbci.cntl&lt;BR /&gt;&lt;BR /&gt;for i in `sed -n '/^LV/p' $CNTL |awk -F\" '{print $4}'`&lt;BR /&gt;do&lt;BR /&gt;# ok - here I check to see if a filesystem $i is mounted&lt;BR /&gt;# don't want output - so I send it to /dev/null&lt;BR /&gt;mount |grep $i &amp;gt;/dev/null&lt;BR /&gt;&lt;BR /&gt;# however - $? still has the return code&lt;BR /&gt;# so, I check to see if it is not equal to 0 (successs)&lt;BR /&gt;if [ $? -ne 0 ]&lt;BR /&gt;&lt;BR /&gt;# if it isn't then echo the fact that it isn't mounted&lt;BR /&gt;then&lt;BR /&gt;        echo "$i is not mounted!!!"&lt;BR /&gt;fi&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 01 Apr 2005 13:20:40 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/status-of-previous-command/m-p/3516393#M219096</guid>
      <dc:creator>Geoff Wild</dc:creator>
      <dc:date>2005-04-01T13:20:40Z</dc:date>
    </item>
    <item>
      <title>Re: Status of Previous command ?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/status-of-previous-command/m-p/3516394#M219097</link>
      <description>Thanks Stephenson , for further explanations. echo $? is applicable for any command. &lt;BR /&gt;&lt;BR /&gt;ex: # ps -ef | grep pmon&lt;BR /&gt;     #  userdel abc&lt;BR /&gt;&lt;BR /&gt;and thanks for showing the built in test for file testing , if exists , writable or executable etc.&lt;BR /&gt;&lt;BR /&gt;Thanks so much. Thanks Geof and all who replied.&lt;BR /&gt;&lt;BR /&gt;Points Assigned **&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Veri.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;     &lt;BR /&gt;</description>
      <pubDate>Fri, 01 Apr 2005 13:47:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/status-of-previous-command/m-p/3516394#M219097</guid>
      <dc:creator>rveri</dc:creator>
      <dc:date>2005-04-01T13:47:12Z</dc:date>
    </item>
  </channel>
</rss>

