<?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: script question in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/script-question/m-p/4112941#M313614</link>
    <description>if i do not use the "-" as su - wbs , is the path is set to what's in /etc/profile?&lt;BR /&gt;Thanks</description>
    <pubDate>Thu, 06 Dec 2007 16:25:07 GMT</pubDate>
    <dc:creator>navin</dc:creator>
    <dc:date>2007-12-06T16:25:07Z</dc:date>
    <item>
      <title>script question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-question/m-p/4112935#M313608</link>
      <description>Could you please let me know if i can use su -in the startup script as below.I need to use as su - wbs .Thanks Much &lt;BR /&gt;&lt;BR /&gt;#!/bin/sh&lt;BR /&gt;&lt;BR /&gt;if [ $# -ne 1 ]; then&lt;BR /&gt;        echo "Usage: $0 {start|stop|restart}"&lt;BR /&gt;        exit 1&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;WBSBIN=/export/home/appl/abot/sw/wbs/wb07/bin:/export/home/appl/abot/sw/wbs/ws07/bin&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;case "$1" in&lt;BR /&gt;        'start')&lt;BR /&gt;                echo "Starting wbs"&lt;BR /&gt;                 sleep 8&lt;BR /&gt;                /bin/su - wbs -c "$WBSBIN/wbs  start"&lt;BR /&gt;                ;;&lt;BR /&gt;        'stop')&lt;BR /&gt;                echo "Stopping wbs"&lt;BR /&gt;                /bin/su - wbs -c "$WBSBIN/wbs stop"&lt;BR /&gt;               ;;&lt;BR /&gt;esac&lt;BR /&gt;#</description>
      <pubDate>Thu, 06 Dec 2007 16:02:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-question/m-p/4112935#M313608</guid>
      <dc:creator>navin</dc:creator>
      <dc:date>2007-12-06T16:02:28Z</dc:date>
    </item>
    <item>
      <title>Re: script question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-question/m-p/4112936#M313609</link>
      <description>Greetings,&lt;BR /&gt;&lt;BR /&gt;Yes... if its root executing the script otherwise it will ask for the passwd and so the only alternative would be to use sudo and give that user the root priviledge to execute this script...&lt;BR /&gt;&lt;BR /&gt;All the best&lt;BR /&gt;Victor</description>
      <pubDate>Thu, 06 Dec 2007 16:10:38 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-question/m-p/4112936#M313609</guid>
      <dc:creator>Victor BERRIDGE</dc:creator>
      <dc:date>2007-12-06T16:10:38Z</dc:date>
    </item>
    <item>
      <title>Re: script question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-question/m-p/4112937#M313610</link>
      <description>Yes, you can be you will probably not get the results you want and the command may hang.&lt;BR /&gt;&lt;BR /&gt;I know you want to use "su -" so that user wbs's .profile will be sourced and the environment is set. The problem is that on HP-UX, most .profile's have commands which are terminal-related and expect stdin to be a terminal --- which it isn't under rc.&lt;BR /&gt;&lt;BR /&gt;There are two approaches that will work:&lt;BR /&gt;1) Edit .profile and surround commands like tset, tput, tabs with:&lt;BR /&gt;if [[ -t 0 ]]&lt;BR /&gt;  then&lt;BR /&gt;    tset ..&lt;BR /&gt;    tput ..&lt;BR /&gt;  fi&lt;BR /&gt;&lt;BR /&gt;2) Don't use the "-" in the su command instead use "su wbc -c ...." and thus don't souce the .profile. I typically setup a special file (e.g. /usr/local/bin/wbsenv.sh) and let this file set and export any needed environment variables. I then let wbs's .profile and any rc'ed or cron'ed scripts source the file using the "." (dot) operator.&lt;BR /&gt;e.g.&lt;BR /&gt;&lt;BR /&gt;. /usr/local/bin/wbsenv.sh&lt;BR /&gt;case "${1}" in&lt;BR /&gt;start)&lt;BR /&gt;&lt;BR /&gt;This way, you change the environment variables in one place and all scripts work.&lt;BR /&gt;NOTE: Do not use an exit or return statement in the sourced file because this will exit the foreground process. The "." command does not spawn a child process but rather includes the file just as though it were part of the main script.&lt;BR /&gt;</description>
      <pubDate>Thu, 06 Dec 2007 16:13:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-question/m-p/4112937#M313610</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2007-12-06T16:13:28Z</dc:date>
    </item>
    <item>
      <title>Re: script question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-question/m-p/4112938#M313611</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;I don't know if you made a typo, but &lt;BR /&gt;&lt;BR /&gt;$WBSBIN&lt;BR /&gt;will give you &lt;BR /&gt;&lt;BR /&gt;/export/home/appl/abot/sw/wbs/wb07/bin:/export/home/appl/abot/sw/wbs/ws07/bin/wbs&lt;BR /&gt;&lt;BR /&gt;I think this should be&lt;BR /&gt;&lt;BR /&gt;WBSBIN=/export/home/appl/abot/sw/wbs/wb07/bin&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Robert-Jan</description>
      <pubDate>Thu, 06 Dec 2007 16:15:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-question/m-p/4112938#M313611</guid>
      <dc:creator>Robert-Jan Goossens</dc:creator>
      <dc:date>2007-12-06T16:15:49Z</dc:date>
    </item>
    <item>
      <title>Re: script question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-question/m-p/4112939#M313612</link>
      <description>And I would test if interactive or batch shell by adding a test of the sort in .profile of wbs:&lt;BR /&gt;  if [[ $- = *i* ]]&lt;BR /&gt;  then&lt;BR /&gt;#Inetracitve shell so set term etc...&lt;BR /&gt;          stty erase "^H" kill "^U" intr "^C" eof "^D"&lt;BR /&gt;          stty hupcl ixon ixoff opost&lt;BR /&gt;  fi&lt;BR /&gt;&lt;BR /&gt;All the best&lt;BR /&gt;Victor</description>
      <pubDate>Thu, 06 Dec 2007 16:15:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-question/m-p/4112939#M313612</guid>
      <dc:creator>Victor BERRIDGE</dc:creator>
      <dc:date>2007-12-06T16:15:54Z</dc:date>
    </item>
    <item>
      <title>Re: script question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-question/m-p/4112940#M313613</link>
      <description>I agree with the secnd approch ..but coupd help me with more detail.&lt;BR /&gt;Thanks</description>
      <pubDate>Thu, 06 Dec 2007 16:18:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-question/m-p/4112940#M313613</guid>
      <dc:creator>navin</dc:creator>
      <dc:date>2007-12-06T16:18:10Z</dc:date>
    </item>
    <item>
      <title>Re: script question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-question/m-p/4112941#M313614</link>
      <description>if i do not use the "-" as su - wbs , is the path is set to what's in /etc/profile?&lt;BR /&gt;Thanks</description>
      <pubDate>Thu, 06 Dec 2007 16:25:07 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-question/m-p/4112941#M313614</guid>
      <dc:creator>navin</dc:creator>
      <dc:date>2007-12-06T16:25:07Z</dc:date>
    </item>
    <item>
      <title>Re: script question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-question/m-p/4112942#M313615</link>
      <description>The PATH in rc is rather sparse and if you examine the parent script /sbin/rc you will find that PATH is set to /sbin. However, your sourced file can set or augment PATH in any way that you choose.</description>
      <pubDate>Thu, 06 Dec 2007 16:31:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-question/m-p/4112942#M313615</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2007-12-06T16:31:12Z</dc:date>
    </item>
    <item>
      <title>Re: script question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-question/m-p/4112943#M313616</link>
      <description>Ofcourse you can use su -wbs&lt;BR /&gt;&lt;BR /&gt;#!/bin/sh&lt;BR /&gt;&lt;BR /&gt;if [ $# -ne 1 ]; then&lt;BR /&gt;echo "Usage: $0 {start|stop|restart}"&lt;BR /&gt;exit 1&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;WBSBIN=/export/home/appl/abot/sw/wbs/wb07/bin:/export/home/appl/abot/sw/wbs/ws07/bin&lt;BR /&gt;&lt;BR /&gt;case "$1" in&lt;BR /&gt;'start')&lt;BR /&gt;echo "Starting wbs"&lt;BR /&gt;sleep 8&lt;BR /&gt;&lt;BR /&gt;su - wbs &amp;lt;&lt;END&gt;&lt;/END&gt;&lt;BR /&gt;"$WBSBIN/wbs start"&lt;BR /&gt;exit&lt;BR /&gt;END&lt;BR /&gt;;;&lt;BR /&gt;'stop')&lt;BR /&gt;echo "Stopping wbs"&lt;BR /&gt;&lt;BR /&gt;su - wbs &amp;lt;&lt;END&gt;&lt;/END&gt;"$WBSBIN/wbs stop"&lt;BR /&gt;exit&lt;BR /&gt;END&lt;BR /&gt;;;&lt;BR /&gt;esac&lt;BR /&gt;#&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;You can easily see the format&lt;BR /&gt;&lt;BR /&gt;su - &lt;USER&gt; &amp;lt;&lt;END&gt;&lt;/END&gt;  execute the commands with the user&lt;BR /&gt;exit&lt;BR /&gt;&lt;BR /&gt;END&lt;BR /&gt;&lt;BR /&gt;With best regards&lt;BR /&gt;-NKG-&lt;/USER&gt;</description>
      <pubDate>Fri, 07 Dec 2007 08:13:06 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-question/m-p/4112943#M313616</guid>
      <dc:creator>Nitin Kumar Gupta</dc:creator>
      <dc:date>2007-12-07T08:13:06Z</dc:date>
    </item>
  </channel>
</rss>

