<?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: Determining user's current shell in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/determining-user-s-current-shell/m-p/2667061#M931837</link>
    <description>Hi,&lt;BR /&gt;&lt;BR /&gt;The echo is redundant.&lt;BR /&gt;&lt;BR /&gt;Instead of ps -fp `echo $$`, ps -fp $$ alone is sufficient.&lt;BR /&gt;&lt;BR /&gt;# ps -fp $$|tail -1|awk '{print $8}'&lt;BR /&gt;&lt;BR /&gt;shell_used=`ps -fp $$|tail -1|awk '{print $8}'`&lt;BR /&gt;&lt;BR /&gt;Hope this helps. Regards.&lt;BR /&gt;&lt;BR /&gt;Steven Sim Kok Leong&lt;BR /&gt;</description>
    <pubDate>Tue, 19 Feb 2002 07:18:35 GMT</pubDate>
    <dc:creator>Steven Sim Kok Leong</dc:creator>
    <dc:date>2002-02-19T07:18:35Z</dc:date>
    <item>
      <title>Determining user's current shell</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/determining-user-s-current-shell/m-p/2667053#M931829</link>
      <description>I need to check if the user's current shell is csh.&lt;BR /&gt;$shell isn't foolproof, and I'm sure there must be a more elegant alternative to running a csh-specific command and checking $?.&lt;BR /&gt;Any ideas?</description>
      <pubDate>Tue, 19 Feb 2002 05:31:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/determining-user-s-current-shell/m-p/2667053#M931829</guid>
      <dc:creator>Deepak Extross</dc:creator>
      <dc:date>2002-02-19T05:31:49Z</dc:date>
    </item>
    <item>
      <title>Re: Determining user's current shell</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/determining-user-s-current-shell/m-p/2667054#M931830</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;login shell can be extracted from /etc/passwd. For current shell, I prefer the easier way of checking the last access timestamp of the .profile, .cshrc, .bashrc, .dtprofile etc.&lt;BR /&gt;&lt;BR /&gt;1) Check user profile access time, eg. for csh,&lt;BR /&gt;&lt;BR /&gt;$ ls -lu .cshrc &lt;BR /&gt;- -rw-r--r-- 1 user1 users 814 Feb 18 20:02 .cshrc &lt;BR /&gt;$ csh &lt;BR /&gt;sys 21: ls -lu .cshrc &lt;BR /&gt;- -rw-r--r-- 1 user1 users 814 Feb 19 13:50 .cshrc &lt;BR /&gt;&lt;BR /&gt;2) Use syntax testing:&lt;BR /&gt;&lt;BR /&gt;For sh/ksh/bash,&lt;BR /&gt;# export a=1&lt;BR /&gt;&lt;BR /&gt;For csh, tcsh,&lt;BR /&gt;# echo &amp;gt;/dev/null 2&amp;gt;&amp;amp;1&lt;BR /&gt;Ambiguous output redirect.&lt;BR /&gt;# echo $?&lt;BR /&gt;Variable syntax.&lt;BR /&gt;&lt;BR /&gt;Hope this helps. Regards.&lt;BR /&gt;&lt;BR /&gt;Steven Sim Kok Leong</description>
      <pubDate>Tue, 19 Feb 2002 05:51:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/determining-user-s-current-shell/m-p/2667054#M931830</guid>
      <dc:creator>Steven Sim Kok Leong</dc:creator>
      <dc:date>2002-02-19T05:51:48Z</dc:date>
    </item>
    <item>
      <title>Re: Determining user's current shell</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/determining-user-s-current-shell/m-p/2667055#M931831</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;One issue with using the last access timestamps on .cshrc user profile is that the user can skip its execution (if he wants to) by executing:&lt;BR /&gt;&lt;BR /&gt;# csh -f&lt;BR /&gt;&lt;BR /&gt;Thus, a syntax check though more inconvenient is still more reliable:&lt;BR /&gt;&lt;BR /&gt;For sh/ksh/bash:&lt;BR /&gt;# setenv&lt;BR /&gt;sh: setenv:  not found.&lt;BR /&gt;&lt;BR /&gt;For csh:&lt;BR /&gt;sys 21: setenv&lt;BR /&gt;setenv: Too few arguments.&lt;BR /&gt;&lt;BR /&gt;Hope this helps. Regards.&lt;BR /&gt;&lt;BR /&gt;Steven Sim Kok Leong</description>
      <pubDate>Tue, 19 Feb 2002 06:05:26 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/determining-user-s-current-shell/m-p/2667055#M931831</guid>
      <dc:creator>Steven Sim Kok Leong</dc:creator>
      <dc:date>2002-02-19T06:05:26Z</dc:date>
    </item>
    <item>
      <title>Re: Determining user's current shell</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/determining-user-s-current-shell/m-p/2667056#M931832</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;The $SHELL variable only works for the login shell which can be extracted from /etc/passwd:&lt;BR /&gt;&lt;BR /&gt;$ echo $SHELL             &lt;BR /&gt;/usr/bin/sh&lt;BR /&gt;$ csh&lt;BR /&gt;sys 21: echo $SHELL&lt;BR /&gt;/usr/bin/sh&lt;BR /&gt;&lt;BR /&gt;If you wish to prevent $SHELL from being tampered, you can add this in your /etc/profile between the traps:&lt;BR /&gt;&lt;BR /&gt;readonly SHELL&lt;BR /&gt;&lt;BR /&gt;Hope this helps. Regards.&lt;BR /&gt;&lt;BR /&gt;Steven Sim Kok Leong</description>
      <pubDate>Tue, 19 Feb 2002 06:12:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/determining-user-s-current-shell/m-p/2667056#M931832</guid>
      <dc:creator>Steven Sim Kok Leong</dc:creator>
      <dc:date>2002-02-19T06:12:35Z</dc:date>
    </item>
    <item>
      <title>Re: Determining user's current shell</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/determining-user-s-current-shell/m-p/2667057#M931833</link>
      <description>hi,&lt;BR /&gt;&lt;BR /&gt;how about:&lt;BR /&gt;&lt;BR /&gt;env | egrep 'csh|ksh'&lt;BR /&gt;&lt;BR /&gt;-Shabu</description>
      <pubDate>Tue, 19 Feb 2002 06:42:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/determining-user-s-current-shell/m-p/2667057#M931833</guid>
      <dc:creator>SHABU KHAN</dc:creator>
      <dc:date>2002-02-19T06:42:19Z</dc:date>
    </item>
    <item>
      <title>Re: Determining user's current shell</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/determining-user-s-current-shell/m-p/2667058#M931834</link>
      <description>Hi Shabu,&lt;BR /&gt;I'm looking for current shell, not default shell.&lt;BR /&gt;To make matters worse, the user can have multiple telnet sessions open, each running a different shell.&lt;BR /&gt;Syntax-testing as suggested by Steven will definitely work, but I was looking for a more elegant solution.</description>
      <pubDate>Tue, 19 Feb 2002 06:53:16 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/determining-user-s-current-shell/m-p/2667058#M931834</guid>
      <dc:creator>Deepak Extross</dc:creator>
      <dc:date>2002-02-19T06:53:16Z</dc:date>
    </item>
    <item>
      <title>Re: Determining user's current shell</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/determining-user-s-current-shell/m-p/2667059#M931835</link>
      <description>Hi Deepak,&lt;BR /&gt;&lt;BR /&gt;For different windows, if the prompt is different for each profile, .cshrc etc then the prompt can be used to identify the shell a user is current running, ie.&lt;BR /&gt;&lt;BR /&gt;sh/ksh/bash:&lt;BR /&gt;&lt;BR /&gt;$ ksh&lt;BR /&gt;$ &lt;BR /&gt;$ &lt;BR /&gt;&lt;BR /&gt;csh/tcsh:&lt;BR /&gt;&lt;BR /&gt;$ csh&lt;BR /&gt;sys 21: &lt;BR /&gt;sys 21: &lt;BR /&gt;&lt;BR /&gt;In .cshrc,&lt;BR /&gt;&lt;BR /&gt;set prompt = "$system \!: "&lt;BR /&gt;&lt;BR /&gt;Hope this helps. Regards.</description>
      <pubDate>Tue, 19 Feb 2002 07:01:43 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/determining-user-s-current-shell/m-p/2667059#M931835</guid>
      <dc:creator>Steven Sim Kok Leong</dc:creator>
      <dc:date>2002-02-19T07:01:43Z</dc:date>
    </item>
    <item>
      <title>Re: Determining user's current shell</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/determining-user-s-current-shell/m-p/2667060#M931836</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;I think I have found the elegant solution you wanted:&lt;BR /&gt;&lt;BR /&gt;Execute this:&lt;BR /&gt;&lt;BR /&gt;# ps -fp `echo $$`&lt;BR /&gt;&lt;BR /&gt;$ ksh&lt;BR /&gt;$ ps -fp `echo $$`&lt;BR /&gt;     UID   PID  PPID  C    STIME TTY       TIME COMMAND&lt;BR /&gt; user1 16088 16079  0 15:01:49 pts/0     0:00 ksh&lt;BR /&gt;&lt;BR /&gt;$ csh&lt;BR /&gt;sys 21: ps -fp `echo $$`&lt;BR /&gt;     UID   PID  PPID  C    STIME TTY       TIME COMMAND&lt;BR /&gt; user1 16334 16088  0 15:06:28 pts/0     0:00 csh&lt;BR /&gt;&lt;BR /&gt;sys 22: sh&lt;BR /&gt;$ ps -fp `echo $$`&lt;BR /&gt;     UID   PID  PPID  C    STIME TTY       TIME COMMAND&lt;BR /&gt; user1 16345 16334  0 15:06:40 pts/0     0:00 sh&lt;BR /&gt;&lt;BR /&gt;You can thus incorporate this in your script eg:&lt;BR /&gt;&lt;BR /&gt;shell_used=`ps -fp `echo $$`|tail -1|awk '{print $8}'`&lt;BR /&gt;&lt;BR /&gt;Hope this helps. Regards.&lt;BR /&gt;&lt;BR /&gt;Steven Sim Kok Leong</description>
      <pubDate>Tue, 19 Feb 2002 07:09:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/determining-user-s-current-shell/m-p/2667060#M931836</guid>
      <dc:creator>Steven Sim Kok Leong</dc:creator>
      <dc:date>2002-02-19T07:09:20Z</dc:date>
    </item>
    <item>
      <title>Re: Determining user's current shell</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/determining-user-s-current-shell/m-p/2667061#M931837</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;The echo is redundant.&lt;BR /&gt;&lt;BR /&gt;Instead of ps -fp `echo $$`, ps -fp $$ alone is sufficient.&lt;BR /&gt;&lt;BR /&gt;# ps -fp $$|tail -1|awk '{print $8}'&lt;BR /&gt;&lt;BR /&gt;shell_used=`ps -fp $$|tail -1|awk '{print $8}'`&lt;BR /&gt;&lt;BR /&gt;Hope this helps. Regards.&lt;BR /&gt;&lt;BR /&gt;Steven Sim Kok Leong&lt;BR /&gt;</description>
      <pubDate>Tue, 19 Feb 2002 07:18:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/determining-user-s-current-shell/m-p/2667061#M931837</guid>
      <dc:creator>Steven Sim Kok Leong</dc:creator>
      <dc:date>2002-02-19T07:18:35Z</dc:date>
    </item>
    <item>
      <title>Re: Determining user's current shell</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/determining-user-s-current-shell/m-p/2667062#M931838</link>
      <description>Thanks, Steven!&lt;BR /&gt;That deserves a bunny :-)</description>
      <pubDate>Tue, 19 Feb 2002 08:07:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/determining-user-s-current-shell/m-p/2667062#M931838</guid>
      <dc:creator>Deepak Extross</dc:creator>
      <dc:date>2002-02-19T08:07:39Z</dc:date>
    </item>
    <item>
      <title>Re: Determining user's current shell</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/determining-user-s-current-shell/m-p/2667063#M931839</link>
      <description>Hi Deepak,&lt;BR /&gt;&lt;BR /&gt;Probably best to just use "ps -p $$", then you don't have to worry about the timestamp being 1 or 2 fields long:&lt;BR /&gt;&lt;BR /&gt;shell_used=`ps -p $$ | awk /:/'{print $4}'`&lt;BR /&gt;&lt;BR /&gt;Rgds, Robin.</description>
      <pubDate>Tue, 19 Feb 2002 08:11:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/determining-user-s-current-shell/m-p/2667063#M931839</guid>
      <dc:creator>Robin Wakefield</dc:creator>
      <dc:date>2002-02-19T08:11:18Z</dc:date>
    </item>
    <item>
      <title>Re: Determining user's current shell</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/determining-user-s-current-shell/m-p/2667064#M931840</link>
      <description>Hi&lt;BR /&gt;&lt;BR /&gt;If you start from another shell or not.&lt;BR /&gt;&lt;BR /&gt;shell in lowercase is set to /usr/bin/csh if you are using csh.&lt;BR /&gt;&lt;BR /&gt;Otherwise if your shell has been open for a while there can be 9 parameters with the 9th as shell name&lt;BR /&gt;&lt;BR /&gt;This works&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;#!/sbin/sh&lt;BR /&gt;MYSHELL=$(ps -fp $$|tail -1|sed -e 's/^.* //' -e 's/-//')&lt;BR /&gt;&lt;BR /&gt;run as . showshell&lt;BR /&gt;&lt;BR /&gt;Then MYSHELL is correct or adjust the previous&lt;BR /&gt;entry.&lt;BR /&gt;&lt;BR /&gt;            Steve Steel</description>
      <pubDate>Tue, 19 Feb 2002 08:15:33 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/determining-user-s-current-shell/m-p/2667064#M931840</guid>
      <dc:creator>Steve Steel</dc:creator>
      <dc:date>2002-02-19T08:15:33Z</dc:date>
    </item>
  </channel>
</rss>

