<?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: how to change shell within the script in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-change-shell-within-the-script/m-p/5195563#M462473</link>
    <description>EVERY script must start with #! on the first line followed by the interpreter you want to use for your script. These are examples of different interpreters:&lt;BR /&gt; &lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;#!/usr/bin/ksh&lt;BR /&gt;#!/usr/bin/awk&lt;BR /&gt;#!/usr/local/bin/bash&lt;BR /&gt; &lt;BR /&gt;and so on. A script is a set of instructions that are designed to be run by a specific program. Whether the program is also your shell or some other program is not important. If you do not have the #! line in your script, then you script will be run by the current shell -- not a good idea at all. Always specify the #! line for every script.</description>
    <pubDate>Thu, 27 Aug 2009 03:00:48 GMT</pubDate>
    <dc:creator>Bill Hassell</dc:creator>
    <dc:date>2009-08-27T03:00:48Z</dc:date>
    <item>
      <title>how to change shell within the script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-change-shell-within-the-script/m-p/5195560#M462470</link>
      <description>I have an script which starts with #!/bin/sh but my native shell is ksh. So in the script, I say echo $SHELL after /bin/shell line and shell is ksh.&lt;BR /&gt;&lt;BR /&gt;I just want shell changed for this session only.  How can I change my sheel from ksh to bsh within the script?&lt;BR /&gt;&lt;BR /&gt;Thanks</description>
      <pubDate>Wed, 26 Aug 2009 21:24:37 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-change-shell-within-the-script/m-p/5195560#M462470</guid>
      <dc:creator>vz7r1x</dc:creator>
      <dc:date>2009-08-26T21:24:37Z</dc:date>
    </item>
    <item>
      <title>Re: how to change shell within the script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-change-shell-within-the-script/m-p/5195561#M462471</link>
      <description>Hi:&lt;BR /&gt;&lt;BR /&gt;&amp;gt;  How can I change my sheel from ksh to bsh within the script?&lt;BR /&gt;&lt;BR /&gt;You don't have to if your script begins with a "she-bang" interpreter line.  In HP-uX:&lt;BR /&gt;&lt;BR /&gt;#!/bin/sh&lt;BR /&gt;&lt;BR /&gt;...is equivalent to:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;&lt;BR /&gt;...which is the POSIX shell --- the HP-UX standard.  You login shell (as defined in '/etc/passwd') might be the Korn shell ('/usr/bin/ksh') but your script will run as the POSIX shell when your interpreter line reads:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;&lt;BR /&gt;(or)&lt;BR /&gt;&lt;BR /&gt;#/bin/sh&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Wed, 26 Aug 2009 21:31:50 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-change-shell-within-the-script/m-p/5195561#M462471</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2009-08-26T21:31:50Z</dc:date>
    </item>
    <item>
      <title>Re: how to change shell within the script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-change-shell-within-the-script/m-p/5195562#M462472</link>
      <description>&lt;!--!*#--&gt;&amp;gt; I just want [...]&lt;BR /&gt;&lt;BR /&gt;I don't know what that means.  If the script&lt;BR /&gt;starts with "#!/bin/sh", then that's what&lt;BR /&gt;gets run to interpret the script.&lt;BR /&gt;&lt;BR /&gt;&amp;gt; So in the script, I say echo $SHELL after&lt;BR /&gt;&amp;gt; /bin/shell line and shell is ksh.&lt;BR /&gt;&lt;BR /&gt;If that bothers you, then you could set SHELL &lt;BR /&gt;to some other value (in your script).  I&lt;BR /&gt;don't know how that will help you, but you&lt;BR /&gt;can do it.&lt;BR /&gt;&lt;BR /&gt;Is there some actual problem which you are&lt;BR /&gt;trying to solve?</description>
      <pubDate>Wed, 26 Aug 2009 21:35:21 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-change-shell-within-the-script/m-p/5195562#M462472</guid>
      <dc:creator>Steven Schweda</dc:creator>
      <dc:date>2009-08-26T21:35:21Z</dc:date>
    </item>
    <item>
      <title>Re: how to change shell within the script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-change-shell-within-the-script/m-p/5195563#M462473</link>
      <description>EVERY script must start with #! on the first line followed by the interpreter you want to use for your script. These are examples of different interpreters:&lt;BR /&gt; &lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;#!/usr/bin/ksh&lt;BR /&gt;#!/usr/bin/awk&lt;BR /&gt;#!/usr/local/bin/bash&lt;BR /&gt; &lt;BR /&gt;and so on. A script is a set of instructions that are designed to be run by a specific program. Whether the program is also your shell or some other program is not important. If you do not have the #! line in your script, then you script will be run by the current shell -- not a good idea at all. Always specify the #! line for every script.</description>
      <pubDate>Thu, 27 Aug 2009 03:00:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-change-shell-within-the-script/m-p/5195563#M462473</guid>
      <dc:creator>Bill Hassell</dc:creator>
      <dc:date>2009-08-27T03:00:48Z</dc:date>
    </item>
    <item>
      <title>Re: how to change shell within the script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-change-shell-within-the-script/m-p/5195564#M462474</link>
      <description>&lt;!--!*#--&gt;&amp;gt; EVERY script must start with #! [...]&lt;BR /&gt;&lt;BR /&gt;&amp;gt; If you do not have the #! line [...]&lt;BR /&gt;&lt;BR /&gt;Make up your mind.  (Or else don't say "must"&lt;BR /&gt;when you really mean "should".)</description>
      <pubDate>Thu, 27 Aug 2009 03:44:51 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-change-shell-within-the-script/m-p/5195564#M462474</guid>
      <dc:creator>Steven Schweda</dc:creator>
      <dc:date>2009-08-27T03:44:51Z</dc:date>
    </item>
    <item>
      <title>Re: how to change shell within the script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-change-shell-within-the-script/m-p/5195565#M462475</link>
      <description>&amp;gt;I say echo $SHELL after /bin/sh line and shell is ksh.&lt;BR /&gt;&lt;BR /&gt;SHELL is set by login(1).  And just about the only program that looks at $SHELL is make.</description>
      <pubDate>Thu, 27 Aug 2009 07:03:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-change-shell-within-the-script/m-p/5195565#M462475</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2009-08-27T07:03:28Z</dc:date>
    </item>
    <item>
      <title>Re: how to change shell within the script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-change-shell-within-the-script/m-p/5195566#M462476</link>
      <description>bsh is posix shell</description>
      <pubDate>Thu, 27 Aug 2009 08:12:38 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-change-shell-within-the-script/m-p/5195566#M462476</guid>
      <dc:creator>isunrise_1</dc:creator>
      <dc:date>2009-08-27T08:12:38Z</dc:date>
    </item>
    <item>
      <title>Re: how to change shell within the script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-change-shell-within-the-script/m-p/5195567#M462477</link>
      <description>Hi (again):&lt;BR /&gt;&lt;BR /&gt;&amp;gt; bsh is posix shell&lt;BR /&gt;&lt;BR /&gt;Yes, it has Posix compliance.  BUT:  In HP-UX, the standard shell in '/usr/bin/sh' and in '/sbin/sh' is called the "Posix" shell.  The important part is that while the 'bash' or the 'ksh' or other shell may be declared as a user's default shell, you should NEVER change root's default login shell.  For root, only the statically linked '/sbin/sh' will allow you to reboot and startup a system (when '/usr' and the dynamic libraries every other shell needs) isn't mounted.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Thu, 27 Aug 2009 10:47:03 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-change-shell-within-the-script/m-p/5195567#M462477</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2009-08-27T10:47:03Z</dc:date>
    </item>
    <item>
      <title>Re: how to change shell within the script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-change-shell-within-the-script/m-p/5195568#M462478</link>
      <description>Actually, Bill, not every script must start with #!.&lt;BR /&gt;&lt;BR /&gt;There's a little trick you can use to get the shell to use a PATH search to find the Perl interpreter for you:&lt;BR /&gt;&lt;BR /&gt;----&lt;BR /&gt;:&lt;BR /&gt;eval 'exec perl -S $0 ${1+"$@"}'&lt;BR /&gt;        if $running_under_some_shell;&lt;BR /&gt;&lt;BR /&gt;print "Hello world!\n";&lt;BR /&gt;----&lt;BR /&gt;&lt;BR /&gt;I use this when some systems have Perl in /usr/local/bin and others have it in /usr/bin, when I haven't gotten around to symlinking.&lt;BR /&gt;&lt;BR /&gt;The colon sends the script to sh, which runs the "eval/exec" line to fire up Perl on the same file, and then Perl ignores that line because "$running_under_some_shell" on the following line is not set, and proceeds down to the rest of the Perl script.</description>
      <pubDate>Thu, 27 Aug 2009 11:12:05 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-change-shell-within-the-script/m-p/5195568#M462478</guid>
      <dc:creator>mvpel</dc:creator>
      <dc:date>2009-08-27T11:12:05Z</dc:date>
    </item>
    <item>
      <title>Re: how to change shell within the script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-change-shell-within-the-script/m-p/5195569#M462479</link>
      <description>Hi (again):&lt;BR /&gt;&lt;BR /&gt;&amp;gt; mvpel: Actually, Bill, not every script must start with #!.  There's a little trick you can use to get the shell to use a PATH search to find the Perl interpreter for you:&lt;BR /&gt;&lt;BR /&gt;A less obtuse way is simply:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/env perl&lt;BR /&gt;&lt;BR /&gt;(or):&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/env ksh&lt;BR /&gt;&lt;BR /&gt;In which case we could still say that "every script must start with #!" :-)&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Thu, 27 Aug 2009 11:24:42 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-change-shell-within-the-script/m-p/5195569#M462479</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2009-08-27T11:24:42Z</dc:date>
    </item>
    <item>
      <title>Re: how to change shell within the script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-change-shell-within-the-script/m-p/5195570#M462480</link>
      <description>Thanks folks. I was really overwhelmed by the storm of scripting knowledge.</description>
      <pubDate>Thu, 27 Aug 2009 11:30:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-change-shell-within-the-script/m-p/5195570#M462480</guid>
      <dc:creator>vz7r1x</dc:creator>
      <dc:date>2009-08-27T11:30:20Z</dc:date>
    </item>
  </channel>
</rss>

