<?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: who command inside a script thru cron causes error mesg in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/who-command-inside-a-script-thru-cron-causes-error-mesg/m-p/3538689#M222803</link>
    <description>Hi,&lt;BR /&gt;&lt;BR /&gt;and the same is true for "who am I", so put that into the "then" part...&lt;BR /&gt;&lt;BR /&gt;if [ -t 0 ]&lt;BR /&gt;then stty ...&lt;BR /&gt;tabs&lt;BR /&gt;who am I&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;Oh, you'll find those statements in your "/etc/profile" (for years now, seems to be some kind of a tradition to have to fix it manually)...&lt;BR /&gt;&lt;BR /&gt;FWIW,&lt;BR /&gt;Wodisch&lt;BR /&gt;</description>
    <pubDate>Thu, 05 May 2005 17:26:06 GMT</pubDate>
    <dc:creator>Wodisch</dc:creator>
    <dc:date>2005-05-05T17:26:06Z</dc:date>
    <item>
      <title>who command inside a script thru cron causes error mesg</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/who-command-inside-a-script-thru-cron-causes-error-mesg/m-p/3538686#M222800</link>
      <description>We are using a who command in a script that is run from a cronjob. The user is a non-root user. The reason is to two fold. We want to setup seperate history files as each user becomes this application user and also to audit who is running the command.&lt;BR /&gt;Does anyone have any scripting ideas on how to test for the presents of a non-terminal su???&lt;BR /&gt;&lt;BR /&gt;The error message being generated is following:&lt;BR /&gt;&lt;BR /&gt;ttytype: couldn't open /dev/tty for reading&lt;BR /&gt;stty: : Not a typewriter&lt;BR /&gt;&lt;SNIPPED hp="" banner="" message=""&gt;&lt;BR /&gt;Not a terminal&lt;BR /&gt;stty: : Not a typewriter&lt;BR /&gt;stty: : Not a typewriter&lt;BR /&gt;        ^[2     ^[2     ^[2     ^[2     ^[2     ^[2     ^[2     ^[2     ^[2     ^[2     ^[2     ^[2     ^[2     ^[2&lt;BR /&gt;        ^[2     ^[2     ^[2     ^[2     ^[2     ^[2&lt;BR /&gt;    process not attached to terminal&lt;BR /&gt;Usage:  who [-rbtpludAasHTqRm] [am i] [utmp_like_file]&lt;BR /&gt;&lt;BR /&gt;r       run level&lt;BR /&gt;b       boot time&lt;BR /&gt;t       time changes&lt;BR /&gt;p       processes other than getty or users&lt;BR /&gt;l       login processes&lt;BR /&gt;u       useful information&lt;BR /&gt;d       dead processes&lt;BR /&gt;A       accounting information&lt;BR /&gt;a       all (rbtpludA options)&lt;BR /&gt;s       short form of who (no time since last output or pid)&lt;BR /&gt;H       print header&lt;BR /&gt;T       status of tty (+ writable, - not writable, x exclusive open, ? hung)&lt;BR /&gt;q       quick who&lt;BR /&gt;R       print host name&lt;BR /&gt;&lt;/SNIPPED&gt;</description>
      <pubDate>Thu, 05 May 2005 12:01:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/who-command-inside-a-script-thru-cron-causes-error-mesg/m-p/3538686#M222800</guid>
      <dc:creator>Dan Deck</dc:creator>
      <dc:date>2005-05-05T12:01:10Z</dc:date>
    </item>
    <item>
      <title>Re: who command inside a script thru cron causes error mesg</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/who-command-inside-a-script-thru-cron-causes-error-mesg/m-p/3538687#M222801</link>
      <description>if tty -s&lt;BR /&gt;then&lt;BR /&gt;INTERACTIVE=/sbin/true&lt;BR /&gt;else&lt;BR /&gt;INTERACTIVE=/sbin/false&lt;BR /&gt;fi&lt;BR /&gt;</description>
      <pubDate>Thu, 05 May 2005 12:04:00 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/who-command-inside-a-script-thru-cron-causes-error-mesg/m-p/3538687#M222801</guid>
      <dc:creator>RAC_1</dc:creator>
      <dc:date>2005-05-05T12:04:00Z</dc:date>
    </item>
    <item>
      <title>Re: who command inside a script thru cron causes error mesg</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/who-command-inside-a-script-thru-cron-causes-error-mesg/m-p/3538688#M222802</link>
      <description>It's very easy inside a script to test whether or not, stdin (fdes 0) is a tty device.&lt;BR /&gt;&lt;BR /&gt;if [[ -t 0 ]]&lt;BR /&gt;  then&lt;BR /&gt;    echo "Stdin is a terminal/tty device"&lt;BR /&gt;  else&lt;BR /&gt;    echo "It ain't"&lt;BR /&gt;  fi&lt;BR /&gt;</description>
      <pubDate>Thu, 05 May 2005 12:05:07 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/who-command-inside-a-script-thru-cron-causes-error-mesg/m-p/3538688#M222802</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2005-05-05T12:05:07Z</dc:date>
    </item>
    <item>
      <title>Re: who command inside a script thru cron causes error mesg</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/who-command-inside-a-script-thru-cron-causes-error-mesg/m-p/3538689#M222803</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;and the same is true for "who am I", so put that into the "then" part...&lt;BR /&gt;&lt;BR /&gt;if [ -t 0 ]&lt;BR /&gt;then stty ...&lt;BR /&gt;tabs&lt;BR /&gt;who am I&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;Oh, you'll find those statements in your "/etc/profile" (for years now, seems to be some kind of a tradition to have to fix it manually)...&lt;BR /&gt;&lt;BR /&gt;FWIW,&lt;BR /&gt;Wodisch&lt;BR /&gt;</description>
      <pubDate>Thu, 05 May 2005 17:26:06 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/who-command-inside-a-script-thru-cron-causes-error-mesg/m-p/3538689#M222803</guid>
      <dc:creator>Wodisch</dc:creator>
      <dc:date>2005-05-05T17:26:06Z</dc:date>
    </item>
    <item>
      <title>Re: who command inside a script thru cron causes error mesg</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/who-command-inside-a-script-thru-cron-causes-error-mesg/m-p/3538690#M222804</link>
      <description>The problem is that /etc/profile and $HOME/.profile have unprotected terminal commands. As mentioned, you need to go inside these files and use the tty -s command to allow these commands to be run, but skip them if tty -s is false. Commands most commonly found in /etc/profile and .profile are:&lt;BR /&gt; &lt;BR /&gt;tput tabs ttytype tset stty clear&lt;BR /&gt; &lt;BR /&gt;and you might as well skip things like the copyright message, email check, news and /etc/motd when tty -s is false. The who command  has a lot of terminal-dependent options, so you have to limit the options you use. There are a number of other commands for user details in addition to who. These are:&lt;BR /&gt; &lt;BR /&gt;last -R -4 user_name&lt;BR /&gt;/usr/lbin/getprpw (lots of options - see man page)&lt;BR /&gt;logins -xol user_name&lt;BR /&gt; &lt;BR /&gt;</description>
      <pubDate>Thu, 05 May 2005 20:44:44 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/who-command-inside-a-script-thru-cron-causes-error-mesg/m-p/3538690#M222804</guid>
      <dc:creator>Bill Hassell</dc:creator>
      <dc:date>2005-05-05T20:44:44Z</dc:date>
    </item>
  </channel>
</rss>

