<?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: ksh question in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/ksh-question/m-p/2909426#M719781</link>
    <description>Hi Sean,&lt;BR /&gt;&lt;BR /&gt;I would do the following.&lt;BR /&gt;&lt;BR /&gt;umount $mount_poing &amp;gt; /tmp/umount$$ &amp;gt; /dev/null 2&amp;gt;&amp;amp;1&lt;BR /&gt;&lt;BR /&gt;grep "Device busy" /tmp/umount$$ &amp;gt; /dev/null 2&amp;gt;&amp;amp;1&lt;BR /&gt;&lt;BR /&gt;if [ $? = 0 ]&lt;BR /&gt;then&lt;BR /&gt;your_busy_action&lt;BR /&gt;else&lt;BR /&gt;if&lt;BR /&gt;Grep "cannot find" /tmp/umount$$ &amp;gt; /dev/null 2&amp;gt;&amp;amp;1&lt;BR /&gt;&lt;BR /&gt;if [ $? = 0 ]&lt;BR /&gt;then&lt;BR /&gt;your_mnttab_action&lt;BR /&gt;fi&lt;BR /&gt;fi&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;etc.,&lt;BR /&gt;&lt;BR /&gt;Some of the commands exit with appropriate exit codes. For ex., "useradd". It will be much easier to deal with them. So a simple case statement can effectively cover them. &lt;BR /&gt;&lt;BR /&gt;But for comands like mount, we will have to do something like the above.&lt;BR /&gt;&lt;BR /&gt;-Sri</description>
    <pubDate>Thu, 20 Feb 2003 16:39:18 GMT</pubDate>
    <dc:creator>Sridhar Bhaskarla</dc:creator>
    <dc:date>2003-02-20T16:39:18Z</dc:date>
    <item>
      <title>ksh question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ksh-question/m-p/2909420#M719775</link>
      <description>Hello!&lt;BR /&gt;&lt;BR /&gt;What is the easiest way in ksh to get the results of a command into a variable?&lt;BR /&gt;&lt;BR /&gt;For example I want to issue a umount of a directory.  I know I can interogate the return code to see if it's successful.&lt;BR /&gt;&lt;BR /&gt;However I want to grab the output if it's unsucessful to help determine why.&lt;BR /&gt;&lt;BR /&gt;For example if you umount a directory that isn't mounted you get this result:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;-&amp;gt; umount /tmp/sean2343234&lt;BR /&gt;                        &lt;BR /&gt;umount: cannot find /tmp/sean2343234 in /etc/mnttab&lt;BR /&gt;        cannot unmount /tmp/sean2343234&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;While a failure because it is in use gives:&lt;BR /&gt;&lt;BR /&gt;-&amp;gt; umount /tmp&lt;BR /&gt;umount: cannot unmount /tmp : Device busy&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;I need to take different actions based on why it failed so I need to catch the results of the command.&lt;BR /&gt;&lt;BR /&gt;This is fairly urgent as I have to have this script in production on Saturday.&lt;BR /&gt;&lt;BR /&gt;TIA,&lt;BR /&gt;&lt;BR /&gt;Sean&lt;BR /&gt;</description>
      <pubDate>Thu, 20 Feb 2003 16:24:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ksh-question/m-p/2909420#M719775</guid>
      <dc:creator>Sean OB_1</dc:creator>
      <dc:date>2003-02-20T16:24:19Z</dc:date>
    </item>
    <item>
      <title>Re: ksh question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ksh-question/m-p/2909421#M719776</link>
      <description>Hi Sean:&lt;BR /&gt;&lt;BR /&gt;Since well-behaved commands write errors to stderr:&lt;BR /&gt;&lt;BR /&gt;# umount /cdrom 2&amp;gt; /tmp/error.$$&lt;BR /&gt;&lt;BR /&gt;...and then if you wanted to put the contents of /tmp/error.$$ into a variable, do:&lt;BR /&gt;&lt;BR /&gt;# ERRTXT=`&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Thu, 20 Feb 2003 16:32:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ksh-question/m-p/2909421#M719776</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2003-02-20T16:32:54Z</dc:date>
    </item>
    <item>
      <title>Re: ksh question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ksh-question/m-p/2909422#M719777</link>
      <description>What about something like this&lt;BR /&gt;&lt;BR /&gt;umount /tmp/sean2343234 2&amp;gt; /umount.err&lt;BR /&gt;error=$(cat /umount.err)&lt;BR /&gt;&lt;BR /&gt;The first statement will redirect standard error to /umount.err and the second will assign the contents of /umount.err to the variable error.</description>
      <pubDate>Thu, 20 Feb 2003 16:34:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ksh-question/m-p/2909422#M719777</guid>
      <dc:creator>Patrick Wallek</dc:creator>
      <dc:date>2003-02-20T16:34:39Z</dc:date>
    </item>
    <item>
      <title>Re: ksh question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ksh-question/m-p/2909423#M719778</link>
      <description>You could try&lt;BR /&gt;&lt;BR /&gt;export UMERR=`umount /tmp 2&amp;gt;&amp;amp;1`&lt;BR /&gt;&lt;BR /&gt;This will set the value of UMERR to the output of the command.&lt;BR /&gt;&lt;BR /&gt;The only problem that I can think of with this is that it joins all the output into a single line.</description>
      <pubDate>Thu, 20 Feb 2003 16:35:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ksh-question/m-p/2909423#M719778</guid>
      <dc:creator>Chris Wilshaw</dc:creator>
      <dc:date>2003-02-20T16:35:28Z</dc:date>
    </item>
    <item>
      <title>Re: ksh question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ksh-question/m-p/2909424#M719779</link>
      <description>I usually send the std error output to a file and examine the file later in the script if needed.&lt;BR /&gt;..&lt;BR /&gt;ERRORLOG=/tmp/myerror.log&lt;BR /&gt;..&lt;BR /&gt;umount /tmp 2&amp;gt;$ERRORLOG&lt;BR /&gt;..&lt;BR /&gt;</description>
      <pubDate>Thu, 20 Feb 2003 16:37:44 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ksh-question/m-p/2909424#M719779</guid>
      <dc:creator>S.K. Chan</dc:creator>
      <dc:date>2003-02-20T16:37:44Z</dc:date>
    </item>
    <item>
      <title>Re: ksh question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ksh-question/m-p/2909425#M719780</link>
      <description>Hi Sean,&lt;BR /&gt;&lt;BR /&gt;One way to do it:&lt;BR /&gt;&lt;BR /&gt;VAR=$(/usr/sbin/umount /mount/point 2&amp;gt;&amp;amp;1)&lt;BR /&gt;&lt;BR /&gt;--&lt;BR /&gt;Tony</description>
      <pubDate>Thu, 20 Feb 2003 16:38:31 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ksh-question/m-p/2909425#M719780</guid>
      <dc:creator>Tony Contratto</dc:creator>
      <dc:date>2003-02-20T16:38:31Z</dc:date>
    </item>
    <item>
      <title>Re: ksh question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ksh-question/m-p/2909426#M719781</link>
      <description>Hi Sean,&lt;BR /&gt;&lt;BR /&gt;I would do the following.&lt;BR /&gt;&lt;BR /&gt;umount $mount_poing &amp;gt; /tmp/umount$$ &amp;gt; /dev/null 2&amp;gt;&amp;amp;1&lt;BR /&gt;&lt;BR /&gt;grep "Device busy" /tmp/umount$$ &amp;gt; /dev/null 2&amp;gt;&amp;amp;1&lt;BR /&gt;&lt;BR /&gt;if [ $? = 0 ]&lt;BR /&gt;then&lt;BR /&gt;your_busy_action&lt;BR /&gt;else&lt;BR /&gt;if&lt;BR /&gt;Grep "cannot find" /tmp/umount$$ &amp;gt; /dev/null 2&amp;gt;&amp;amp;1&lt;BR /&gt;&lt;BR /&gt;if [ $? = 0 ]&lt;BR /&gt;then&lt;BR /&gt;your_mnttab_action&lt;BR /&gt;fi&lt;BR /&gt;fi&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;etc.,&lt;BR /&gt;&lt;BR /&gt;Some of the commands exit with appropriate exit codes. For ex., "useradd". It will be much easier to deal with them. So a simple case statement can effectively cover them. &lt;BR /&gt;&lt;BR /&gt;But for comands like mount, we will have to do something like the above.&lt;BR /&gt;&lt;BR /&gt;-Sri</description>
      <pubDate>Thu, 20 Feb 2003 16:39:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ksh-question/m-p/2909426#M719781</guid>
      <dc:creator>Sridhar Bhaskarla</dc:creator>
      <dc:date>2003-02-20T16:39:18Z</dc:date>
    </item>
    <item>
      <title>Re: ksh question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ksh-question/m-p/2909427#M719782</link>
      <description>This is what I wanted to do:&lt;BR /&gt;&lt;BR /&gt;VAR=$(/usr/sbin/umount /mount/point 2&amp;gt;&amp;amp;1) &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;I was trying this and couldn't get the syntax right.&lt;BR /&gt;&lt;BR /&gt;Thanks much!&lt;BR /&gt;</description>
      <pubDate>Thu, 20 Feb 2003 18:20:06 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ksh-question/m-p/2909427#M719782</guid>
      <dc:creator>Sean OB_1</dc:creator>
      <dc:date>2003-02-20T18:20:06Z</dc:date>
    </item>
  </channel>
</rss>

