<?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: trap DEBUG in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/trap-debug/m-p/4689231#M658952</link>
    <description>"I have the following lines in my .profile"&lt;BR /&gt;in which users .profile? is it the roots .profile?&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;"change using su - root"&lt;BR /&gt;&lt;BR /&gt;if you switch to root this way, you are getting its environment. Check if the function "history_to_syslog" is still there after switching to root:&lt;BR /&gt;&lt;BR /&gt;# functions</description>
    <pubDate>Wed, 22 Sep 2010 11:09:36 GMT</pubDate>
    <dc:creator>Viktor Balogh</dc:creator>
    <dc:date>2010-09-22T11:09:36Z</dc:date>
    <item>
      <title>trap DEBUG</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/trap-debug/m-p/4689230#M658951</link>
      <description>I have the following lines in my .profile&lt;BR /&gt;echo $- | /usr/bin/grep "i" &amp;gt; /dev/null 2&amp;gt;&amp;amp;1&lt;BR /&gt;if (( $? == 0 )); then&lt;BR /&gt;function history_to_syslog&lt;BR /&gt;{&lt;BR /&gt;typeset -i stat=$?&lt;BR /&gt;typeset cmd&lt;BR /&gt;cmd=$(command fc -ln -0)&lt;BR /&gt;Session:$$, Status:$stat  Runned: $c&lt;BR /&gt;md"&lt;BR /&gt;MY_TTY=`/usr/bin/tty | /usr/bin/sed 's/\/dev\///'`&lt;BR /&gt;MY_ID=`/usr/bin/who | /usr/bin/grep "${MY_TTY}" | /usr/bin/awk '{print $1}'`&lt;BR /&gt;/usr/bin/logger -p daemon.notice -t "euid: ${LOGNAME} id: ${MY_ID} $$" Status ${&lt;BR /&gt;stat} PWD ${PWD} TTY=`tty` \'${cmd#     }\'&lt;BR /&gt;}&lt;BR /&gt;trap 'history_to_syslog' DEBUG&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;i use it to log all the commands to syslog.&lt;BR /&gt;If i run this script in a bash or ksh environment with HISTFILE=~/.bash_history it runs without a problem . if i change to /usr/bin/sh shell (change using su - root) halts after executing a command like it goes through an infinite debugging loop.&lt;BR /&gt;ie if i type ls is shows me the results but i have to press Ctrl-C to get a command prompt. If type a new command i get at the end a command prompt but after that the same problem occurs with additional commands.</description>
      <pubDate>Tue, 21 Sep 2010 09:10:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/trap-debug/m-p/4689230#M658951</guid>
      <dc:creator>Andreas Tsamis</dc:creator>
      <dc:date>2010-09-21T09:10:12Z</dc:date>
    </item>
    <item>
      <title>Re: trap DEBUG</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/trap-debug/m-p/4689231#M658952</link>
      <description>"I have the following lines in my .profile"&lt;BR /&gt;in which users .profile? is it the roots .profile?&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;"change using su - root"&lt;BR /&gt;&lt;BR /&gt;if you switch to root this way, you are getting its environment. Check if the function "history_to_syslog" is still there after switching to root:&lt;BR /&gt;&lt;BR /&gt;# functions</description>
      <pubDate>Wed, 22 Sep 2010 11:09:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/trap-debug/m-p/4689231#M658952</guid>
      <dc:creator>Viktor Balogh</dc:creator>
      <dc:date>2010-09-22T11:09:36Z</dc:date>
    </item>
    <item>
      <title>Re: trap DEBUG</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/trap-debug/m-p/4689232#M658953</link>
      <description>there are both in /.profile (roots) and /home/a_user/.profile (another user). &lt;BR /&gt;When the profile is executed under a bash shell (. /.profile) logging works without a problem. If i change to sh either by su - root (it loads the profile), or just typing sh and then . /.profile from another session i get the above problem. &lt;BR /&gt;#trap -l &lt;BR /&gt;in bash shows me the signals&lt;BR /&gt;in sh shows me nothing &lt;BR /&gt;#trap&lt;BR /&gt;in both&lt;BR /&gt;trap -- history_to_syslog DEBUG&lt;BR /&gt;&lt;BR /&gt;It seems in the case of sh it keeps debuging the commands inside the history_to_syslog function. And i don't know if there is a difference in trap command according to the shell used.</description>
      <pubDate>Thu, 23 Sep 2010 04:06:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/trap-debug/m-p/4689232#M658953</guid>
      <dc:creator>Andreas Tsamis</dc:creator>
      <dc:date>2010-09-23T04:06:54Z</dc:date>
    </item>
    <item>
      <title>Re: trap DEBUG</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/trap-debug/m-p/4689233#M658954</link>
      <description>&amp;gt; And i don't know if there is a difference in trap command according to the shell used.&lt;BR /&gt;&lt;BR /&gt;good point! there should be a difference, since the trap command is a shell builtin. I don't know the exact use of trap in the different shells, so consult the relevant manpage of your shell for more info.&lt;BR /&gt;&lt;BR /&gt;According to a solaris man page (there's a separate man page for trap) the command might have a different name in a different shell:&lt;BR /&gt;&lt;BR /&gt;NAME&lt;BR /&gt;     trap, onintr  -  shell  built-in  functions  to  respond  to&lt;BR /&gt;     (hardware) signals&lt;BR /&gt;&lt;BR /&gt;SYNOPSIS&lt;BR /&gt;  sh&lt;BR /&gt;     trap [ argument n [n2...]]&lt;BR /&gt;&lt;BR /&gt;  csh&lt;BR /&gt;     onintr [-| label]&lt;BR /&gt;&lt;BR /&gt;  ksh&lt;BR /&gt;     *trap [ arg sig [ sig2...]]&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 23 Sep 2010 11:37:38 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/trap-debug/m-p/4689233#M658954</guid>
      <dc:creator>Viktor Balogh</dc:creator>
      <dc:date>2010-09-23T11:37:38Z</dc:date>
    </item>
    <item>
      <title>Re: trap DEBUG</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/trap-debug/m-p/4689234#M658955</link>
      <description>After performing a search in the internet about differences between bash and sh shells it seems that DEBUG and ERR signals are not present in sh shell. &lt;BR /&gt;Is there another way to log all the shell commands in a file?</description>
      <pubDate>Fri, 24 Sep 2010 04:28:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/trap-debug/m-p/4689234#M658955</guid>
      <dc:creator>Andreas Tsamis</dc:creator>
      <dc:date>2010-09-24T04:28:47Z</dc:date>
    </item>
    <item>
      <title>Re: trap DEBUG</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/trap-debug/m-p/4689235#M658956</link>
      <description>Hi Andreas:&lt;BR /&gt;&lt;BR /&gt;&amp;gt; it seems that DEBUG and ERR signals are not present in sh shell.&lt;BR /&gt;&lt;BR /&gt;That is *not* true.  The HP-UX 'sh' found as '/usr/bin/sh' or '/sbin/sh' is a POSIX shell documented as 'sh-posix(1)'.  Look at those manpages, under the discussion of 'trap'. &lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Fri, 24 Sep 2010 11:20:30 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/trap-debug/m-p/4689235#M658956</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2010-09-24T11:20:30Z</dc:date>
    </item>
  </channel>
</rss>

