<?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: common problem in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/common-problem/m-p/2958163#M76986</link>
    <description>use the inbuilt 'trap' command to trap signals.&lt;BR /&gt;&lt;BR /&gt;trap "" 1 2 15&lt;BR /&gt;&lt;BR /&gt;makes your script not respond to a SIGHUP (1), a SIGINT (2, ctrl-c) or SIGTERM (15).</description>
    <pubDate>Thu, 24 Apr 2003 05:55:31 GMT</pubDate>
    <dc:creator>Stuart Browne</dc:creator>
    <dc:date>2003-04-24T05:55:31Z</dc:date>
    <item>
      <title>common problem</title>
      <link>https://community.hpe.com/t5/operating-system-linux/common-problem/m-p/2958159#M76982</link>
      <description>1. how to determine whether or not a command was completed successfully?&lt;BR /&gt;&lt;BR /&gt;2. how can we make sure the variable is not reset?&lt;BR /&gt;&lt;BR /&gt;3. what command can be used in script to lock terminal?</description>
      <pubDate>Thu, 24 Apr 2003 05:03:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/common-problem/m-p/2958159#M76982</guid>
      <dc:creator>neocosmic</dc:creator>
      <dc:date>2003-04-24T05:03:52Z</dc:date>
    </item>
    <item>
      <title>Re: common problem</title>
      <link>https://community.hpe.com/t5/operating-system-linux/common-problem/m-p/2958160#M76983</link>
      <description>1. depends on your shell and program. normally all programs return a value of 0 on successful execution and a non-zero error code for any errors during execution. &lt;BR /&gt;&lt;BR /&gt;and based on youre shell, use an echo $? (ksh, bash, sh etc) and echo $status (csh and tcsh (?)) to know the status. &lt;BR /&gt;&lt;BR /&gt;2. not very clear. variables are there to be set and reset. use set or setenv or export based on your shell and if u need a local or a global variable.&lt;BR /&gt;&lt;BR /&gt;3. how abt scrolling through a loop and read for a passwd and wait until the correct passwd is entered.&lt;BR /&gt;&lt;BR /&gt;hth&lt;BR /&gt;-balaji</description>
      <pubDate>Thu, 24 Apr 2003 05:12:32 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/common-problem/m-p/2958160#M76983</guid>
      <dc:creator>Balaji N</dc:creator>
      <dc:date>2003-04-24T05:12:32Z</dc:date>
    </item>
    <item>
      <title>Re: common problem</title>
      <link>https://community.hpe.com/t5/operating-system-linux/common-problem/m-p/2958161#M76984</link>
      <description>how can ignore the interrupts from other command, while im writing a script to lock terminal?</description>
      <pubDate>Thu, 24 Apr 2003 05:33:03 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/common-problem/m-p/2958161#M76984</guid>
      <dc:creator>neocosmic</dc:creator>
      <dc:date>2003-04-24T05:33:03Z</dc:date>
    </item>
    <item>
      <title>Re: common problem</title>
      <link>https://community.hpe.com/t5/operating-system-linux/common-problem/m-p/2958162#M76985</link>
      <description>1) expanding upon what Balaji said.&lt;BR /&gt;&lt;BR /&gt;If a command completes successfully, it returns a 0 exit.&lt;BR /&gt;&lt;BR /&gt;In most shells (bash, ksh, ash, sh) you can do conditionals upon the exit state, without having to do an 'if' check on the exit value.  For example:&lt;BR /&gt;&lt;BR /&gt;grep -q root /etc/passwd &amp;amp;&amp;amp; echo "I found root in /etc/passwd"&lt;BR /&gt;&lt;BR /&gt;When 'grep' successfully find a pattern in a file, it will return 0.  The '&amp;amp;&amp;amp;' operator states that if there is a successful exit, that the following command should be executed (in this case a simple 'echo').&lt;BR /&gt;&lt;BR /&gt;Using {} and () allows you to make this more complicated.&lt;BR /&gt;&lt;BR /&gt;Other things you can do is to make 'if' descisions directly based upon the exit of a program, rather than checking the $? exit values, for example:&lt;BR /&gt;&lt;BR /&gt;if grep -q root /etc/passwd&lt;BR /&gt;then&lt;BR /&gt;    echo "I found root in the passwd file"&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;This can also be negated:&lt;BR /&gt;&lt;BR /&gt;if ! grep -q root /etc/passwd&lt;BR /&gt;then&lt;BR /&gt;    echo "I couldn't find root in the passwd file"&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;Most people however use the program 'test' to do such checking.  '/usr/bin/test' is usually symbolically linked to '/usr/bin/[' (thus the format:&lt;BR /&gt;&lt;BR /&gt;grep -q root /etc/passwd&lt;BR /&gt;if [ $? -gt 0 ]&lt;BR /&gt;then&lt;BR /&gt;    echo "I couldn't find root in the passwd file"&lt;BR /&gt;fi&lt;BR /&gt;)&lt;BR /&gt;... umm, sorry .. ramble ..&lt;BR /&gt;&lt;BR /&gt;2) Using ksh and bash, you can use the command 'typeset' (in-built shell-function), with the flag '-r' to mark a variable 'read-only'.  It cannot be changed or un-marked as read-only, until the shell is destroyed.</description>
      <pubDate>Thu, 24 Apr 2003 05:52:02 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/common-problem/m-p/2958162#M76985</guid>
      <dc:creator>Stuart Browne</dc:creator>
      <dc:date>2003-04-24T05:52:02Z</dc:date>
    </item>
    <item>
      <title>Re: common problem</title>
      <link>https://community.hpe.com/t5/operating-system-linux/common-problem/m-p/2958163#M76986</link>
      <description>use the inbuilt 'trap' command to trap signals.&lt;BR /&gt;&lt;BR /&gt;trap "" 1 2 15&lt;BR /&gt;&lt;BR /&gt;makes your script not respond to a SIGHUP (1), a SIGINT (2, ctrl-c) or SIGTERM (15).</description>
      <pubDate>Thu, 24 Apr 2003 05:55:31 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/common-problem/m-p/2958163#M76986</guid>
      <dc:creator>Stuart Browne</dc:creator>
      <dc:date>2003-04-24T05:55:31Z</dc:date>
    </item>
    <item>
      <title>Re: common problem</title>
      <link>https://community.hpe.com/t5/operating-system-linux/common-problem/m-p/2958164#M76987</link>
      <description>trap [-lp] [arg] [sigspec ...]&lt;BR /&gt;              The command arg is to  be  read  and  executed  when  the  shell&lt;BR /&gt;              receives  signal(s)  sigspec.  If arg is absent or -, all speci-&lt;BR /&gt;              fied signals are reset to their original values (the values they&lt;BR /&gt;              had  upon entrance to the shell).  If arg is the null string the&lt;BR /&gt;              signal specified by each sigspec is ignored by the shell and  by&lt;BR /&gt;              the  commands it invokes.  If arg is not present and -p has been&lt;BR /&gt;              supplied, then the trap commands associated  with  each  sigspec&lt;BR /&gt;              are  displayed.   If  no arguments are supplied or if only -p is&lt;BR /&gt;              given, trap prints the list of  commands  associated  with  each&lt;BR /&gt;              signal  number.  Each sigspec is either a signal name defined in&lt;BR /&gt;              &lt;SIGNAL.H&gt;, or a signal number.  If a sigspec is  EXIT  (0)  the&lt;BR /&gt;              command arg is executed on exit from the shell.  If a sigspec is&lt;BR /&gt;              DEBUG, the command arg is executed after  every  simple  command&lt;BR /&gt;              (see SHELL GRAMMAR above).  If a sigspec is ERR, the command arg&lt;BR /&gt;              is executed whenever a simple command has a non-zero  exit  sta-&lt;BR /&gt;              tus.  The ERR trap is not executed if the failed command is part&lt;BR /&gt;              of an until or while loop, part of an if statement, part of a &amp;amp;&amp;amp;&lt;BR /&gt;              or  ||  list, or if the command's return value is being inverted&lt;BR /&gt;              via !.  The -l option causes the shell to print a list of signal&lt;BR /&gt;              names  and  their  corresponding  numbers.  Signals ignored upon&lt;BR /&gt;              entry to the shell cannot be trapped or reset.  Trapped  signals&lt;BR /&gt;              are reset to their original values in a child process when it is&lt;BR /&gt;              created.  The return status is false if any sigspec is  invalid;&lt;BR /&gt;              otherwise trap returns true.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;man sh or ksh and search for trap.&lt;BR /&gt;-balaji&lt;/SIGNAL.H&gt;</description>
      <pubDate>Thu, 24 Apr 2003 06:42:13 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/common-problem/m-p/2958164#M76987</guid>
      <dc:creator>Balaji N</dc:creator>
      <dc:date>2003-04-24T06:42:13Z</dc:date>
    </item>
  </channel>
</rss>

