<?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: shell - pre-exec/post-exec command in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-pre-exec-post-exec-command/m-p/5269659#M655862</link>
    <description>HA! Thanks for the reply.  I figured I'd get a reply similar to yours.  Yes, from what I can see, bash (or similarly more advanced shell) is the solution.&lt;BR /&gt;&lt;BR /&gt;Just trying to avoid installing another shell and it's dependencies, that only I will use and cause yet another package that I would have to maintain up to date and patch outside of a standard patch bundle.  &lt;BR /&gt;&lt;BR /&gt;I try to avoid installing software that cannot be maintained by standard patch bundles unless there's an absolute business reason to do so.  This isn't a business requirement; it's a personal one.  If I were to go this route, bash would need to be installed, and maintained, on all my systems.&lt;BR /&gt;&lt;BR /&gt;If I can do it natively, why not?&lt;BR /&gt;&lt;BR /&gt;Anyone else have any other ideas?</description>
    <pubDate>Thu, 13 Jan 2011 16:53:13 GMT</pubDate>
    <dc:creator>Michael Morris</dc:creator>
    <dc:date>2011-01-13T16:53:13Z</dc:date>
    <item>
      <title>shell - pre-exec/post-exec command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-pre-exec-post-exec-command/m-p/5269657#M655860</link>
      <description>Hello all,&lt;BR /&gt;&lt;BR /&gt;In an attempt to avoid installing bash, I'm trying to find if there is a way in HPUX native shells (posix, ksh, csh[last resort]) to always execute a command BEFORE the command typed at the prompt on the commandline.&lt;BR /&gt;&lt;BR /&gt;With bash, I can use the "trap" builtin:&lt;BR /&gt;"If a sigspec is DEBUG, the command arg is executed before every simple command..." -bash(1)&lt;BR /&gt;&lt;BR /&gt;However, with sh-posix, the trap executes after the command runs:&lt;BR /&gt;"If sig is DEBUG, then arg is executed after each command." -sh-posix(1)&lt;BR /&gt;&lt;BR /&gt;In addition to this, I would also appreciate a solution for $PROMPT_COMMAND.  I believe this can, potentially, be accomplished through the aforementioned trap or using command-substitution within the $PS1 variable.  Though for my purposes, I would need to be capable of setting variables within current shell and not sub-shells.&lt;BR /&gt;&lt;BR /&gt;Why on earth do I need this?!?!  I want to display the running command in my title bar :)(actually it's for screen/tmux window names)&lt;BR /&gt;&lt;BR /&gt;I've been looking at this for a while, and I feel I may be thinking inside the box.  Any outside assistance is appreciated.  Perhaps there's something simple I'm overlooking.&lt;BR /&gt;&lt;BR /&gt;An example of what I'm talking about:&lt;BR /&gt;&lt;A href="http://www.twistedmatrix.com/users/glyph/preexec.bash.txt" target="_blank"&gt;http://www.twistedmatrix.com/users/glyph/preexec.bash.txt&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;&lt;BR /&gt;Mike</description>
      <pubDate>Thu, 13 Jan 2011 06:23:57 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-pre-exec-post-exec-command/m-p/5269657#M655860</guid>
      <dc:creator>Michael Morris</dc:creator>
      <dc:date>2011-01-13T06:23:57Z</dc:date>
    </item>
    <item>
      <title>Re: shell - pre-exec/post-exec command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-pre-exec-post-exec-command/m-p/5269658#M655861</link>
      <description>&lt;!--!*#--&gt;&amp;gt; In an attempt to avoid installing bash,&lt;BR /&gt;&amp;gt; [..]&lt;BR /&gt;&lt;BR /&gt;&amp;gt; [...] I may be thinking inside the box.&lt;BR /&gt;&lt;BR /&gt;Inside the wrong box?&lt;BR /&gt;&lt;BR /&gt;&amp;gt; [...] Perhaps there's something simple I'm&lt;BR /&gt;&amp;gt; overlooking.&lt;BR /&gt;&lt;BR /&gt;Like using "bash"?&lt;BR /&gt;&lt;BR /&gt;To me, it seems that a job like this would be&lt;BR /&gt;best handled by the shell, although I was&lt;BR /&gt;unaware that even "bash" could do it.  If&lt;BR /&gt;"bash" _can_ do it, then I'd vote for using&lt;BR /&gt;"bash".  (Which I generally do, but for other&lt;BR /&gt;reasons.)  _Why_ do you shun the obvious&lt;BR /&gt;solution?</description>
      <pubDate>Thu, 13 Jan 2011 12:45:13 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-pre-exec-post-exec-command/m-p/5269658#M655861</guid>
      <dc:creator>Steven Schweda</dc:creator>
      <dc:date>2011-01-13T12:45:13Z</dc:date>
    </item>
    <item>
      <title>Re: shell - pre-exec/post-exec command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-pre-exec-post-exec-command/m-p/5269659#M655862</link>
      <description>HA! Thanks for the reply.  I figured I'd get a reply similar to yours.  Yes, from what I can see, bash (or similarly more advanced shell) is the solution.&lt;BR /&gt;&lt;BR /&gt;Just trying to avoid installing another shell and it's dependencies, that only I will use and cause yet another package that I would have to maintain up to date and patch outside of a standard patch bundle.  &lt;BR /&gt;&lt;BR /&gt;I try to avoid installing software that cannot be maintained by standard patch bundles unless there's an absolute business reason to do so.  This isn't a business requirement; it's a personal one.  If I were to go this route, bash would need to be installed, and maintained, on all my systems.&lt;BR /&gt;&lt;BR /&gt;If I can do it natively, why not?&lt;BR /&gt;&lt;BR /&gt;Anyone else have any other ideas?</description>
      <pubDate>Thu, 13 Jan 2011 16:53:13 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-pre-exec-post-exec-command/m-p/5269659#M655862</guid>
      <dc:creator>Michael Morris</dc:creator>
      <dc:date>2011-01-13T16:53:13Z</dc:date>
    </item>
    <item>
      <title>Re: shell - pre-exec/post-exec command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-pre-exec-post-exec-command/m-p/5269660#M655863</link>
      <description>Hi MIke:&lt;BR /&gt;&lt;BR /&gt;&amp;gt; Just trying to avoid installing another shell and it's dependencies, that only I will use and cause yet another package that I would have to maintain up to date and patch outside of a standard patch bundle.&lt;BR /&gt;&lt;BR /&gt;But, I'm in agreement with Steven: if the bash shell fulfills your need, why re-invent the wheel?  I too, was unaware of the ability to "pre-process".&lt;BR /&gt;&lt;BR /&gt;As for having to "...maintain up to date and patch outside of a standard patch bundle", this shouldn't be a big issue if what you gain (albeit for personal use) is something you can't live without.&lt;BR /&gt;&lt;BR /&gt;If you fetch the 'bash' shell from the HP-UX Porting Centre then you now have the 'depothelper' to collect and install all associated dependencies.  I don't think that that this differs significantly from maintaining any other non-HP-provided add-on product (e.g. 'lsof', 'tusc', etc.).&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Fri, 14 Jan 2011 02:36:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-pre-exec-post-exec-command/m-p/5269660#M655863</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2011-01-14T02:36:54Z</dc:date>
    </item>
    <item>
      <title>Re: shell - pre-exec/post-exec command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-pre-exec-post-exec-command/m-p/5269661#M655864</link>
      <description>&lt;!--!*#--&gt;&amp;gt; Just trying to avoid installing another&lt;BR /&gt;&amp;gt; shell and it's dependencies, that only I&lt;BR /&gt;&lt;BR /&gt;That's "its dependencies".&lt;BR /&gt;&lt;BR /&gt;&amp;gt; will use and cause yet another package that&lt;BR /&gt;&amp;gt; I would have to maintain up to date and&lt;BR /&gt;&amp;gt; patch outside of a standard patch bundle.&lt;BR /&gt;&lt;BR /&gt;Perhaps you can find more users for it.&lt;BR /&gt;&lt;BR /&gt;I can't remember any case where even a pretty&lt;BR /&gt;old "bash" actually _needed_ to be updated or&lt;BR /&gt;patched.  I typically try to remember to&lt;BR /&gt;refresh my "bash" with a newer one when I do&lt;BR /&gt;an OS upgrade or a fresh installation&lt;BR /&gt;somewhere.  I can't remember it ever breaking&lt;BR /&gt;spontaneously.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&amp;gt; [...] 'depothelper' [...]&lt;BR /&gt;&lt;BR /&gt;I tend to build my stuff from the sources, to&lt;BR /&gt;reduce mismatches (and mysteries) with the&lt;BR /&gt;build-time and/or run-time infrastructure,&lt;BR /&gt;but I'll admit that keeping enough of the GNU&lt;BR /&gt;stuff in shape can be a project of its own.</description>
      <pubDate>Fri, 14 Jan 2011 04:24:45 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-pre-exec-post-exec-command/m-p/5269661#M655864</guid>
      <dc:creator>Steven Schweda</dc:creator>
      <dc:date>2011-01-14T04:24:45Z</dc:date>
    </item>
    <item>
      <title>Re: shell - pre-exec/post-exec command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-pre-exec-post-exec-command/m-p/5269662#M655865</link>
      <description>&amp;gt;I want to display the running command in my title bar&lt;BR /&gt;&lt;BR /&gt;I have some shell functions that display the machine and CWD.  I'm not sure how you would get the current command in a real shell.  I'm not sure if $_ is the last command or the last parm on that command.  (It seems it is the latter.)&lt;BR /&gt;&lt;BR /&gt;And this won't work since that is only changed, AFTER the command is finished.</description>
      <pubDate>Fri, 14 Jan 2011 07:01:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-pre-exec-post-exec-command/m-p/5269662#M655865</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2011-01-14T07:01:35Z</dc:date>
    </item>
    <item>
      <title>Re: shell - pre-exec/post-exec command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-pre-exec-post-exec-command/m-p/5269663#M655866</link>
      <description>&amp;gt;If you fetch the 'bash' shell from the HP-UX&lt;BR /&gt;&amp;gt;Porting Centre then you now have the &lt;BR /&gt;&amp;gt;'depothelper' to collect and install all &lt;BR /&gt;&amp;gt;associated dependencies.&lt;BR /&gt;&lt;BR /&gt;Thanks James, I didn't know about depothelper.  Perhaps it will help.  I'll check it out!&lt;BR /&gt;&lt;BR /&gt;&amp;gt;That's "its dependencies".&lt;BR /&gt;&lt;BR /&gt;I'm usually a stickler for that as well.  Thanks for the grammar reminder.&lt;BR /&gt;Hmm... I'll blame it on the recent influx of bad weather in my area. ;)&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&amp;gt;I have some shell functions that display the&lt;BR /&gt;&amp;gt;machine and CWD. I'm not sure how you would&lt;BR /&gt;&amp;gt;get the current command in a real shell. I'm &lt;BR /&gt;&amp;gt;not sure if $_ is the last command or the &lt;BR /&gt;&amp;gt;last parm on that command. (It seems it is &lt;BR /&gt;&amp;gt;the latter.)&lt;BR /&gt;&amp;gt;&lt;BR /&gt;&amp;gt;And this won't work since that is only &amp;gt;changed, AFTER the command is finished.&lt;BR /&gt;&lt;BR /&gt;I am using the mcd function/alias to change the CWD in my prompt.  And I'm currently using $PS1 to change my window title within GNU screen.  I'm trying to switch to tmux which handles the window titling a little different with regards to the running command.&lt;BR /&gt;&lt;BR /&gt;If bash on HPUX works like bash on Linux (i'm assuming it would), you can use "trap 'function_that_changes_title' DEBUG" in your .bashrc and the trap will occur BEFORE the command on the commandline runs.  It also provides $PROMPT_COMMAND instead of just $PS1 which might work better for this task.  With those two abilities, you can change the title before and after the command runs.  So you would be able to change title to the running command, have the command execute, and after it's done, change title back to the hostname (or whatever you wanted it to be).&lt;BR /&gt;&lt;BR /&gt;So far, I'm seeing what I guess I expected to see for replies.  A lot of, "just go with bash".  I appreciate that, as it helps affirm what I've researched.  Thanks to all who have replied!&lt;BR /&gt;&lt;BR /&gt;Anyone else have any other ideas?</description>
      <pubDate>Fri, 14 Jan 2011 17:34:00 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-pre-exec-post-exec-command/m-p/5269663#M655866</guid>
      <dc:creator>Michael Morris</dc:creator>
      <dc:date>2011-01-14T17:34:00Z</dc:date>
    </item>
    <item>
      <title>Re: shell - pre-exec/post-exec command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-pre-exec-post-exec-command/m-p/5269664#M655867</link>
      <description>Thank you to everyone who replied.  I'll heed your advice and run with bash.&lt;BR /&gt;&lt;BR /&gt;It seems to be working great for me so far.  In case you're interested, I've attached a file with the code I'm currently using in my ~/.profile.  I pulled the core pieces from the link in the original post.&lt;BR /&gt;&lt;BR /&gt;When not running under GNU Screen or tmux, it may show the escape codes to the terminal.  However, it looks great when using either of those two applications.&lt;BR /&gt;&lt;BR /&gt;Thanks again for all your insight.</description>
      <pubDate>Tue, 18 Jan 2011 22:24:06 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-pre-exec-post-exec-command/m-p/5269664#M655867</guid>
      <dc:creator>Michael Morris</dc:creator>
      <dc:date>2011-01-18T22:24:06Z</dc:date>
    </item>
    <item>
      <title>Re: shell - pre-exec/post-exec command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-pre-exec-post-exec-command/m-p/5269665#M655868</link>
      <description>Solution was: Install bash.&lt;BR /&gt;Closing thread.</description>
      <pubDate>Tue, 18 Jan 2011 22:25:55 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-pre-exec-post-exec-command/m-p/5269665#M655868</guid>
      <dc:creator>Michael Morris</dc:creator>
      <dc:date>2011-01-18T22:25:55Z</dc:date>
    </item>
  </channel>
</rss>

