Process not attached to terminal

Hi Folks,

When i try to run schedule job on Unix server am getting following errror messges in logs

pic_selection @starting on Fri Feb 5 01:53:06 GMT 2010
-------------------------------------------------------------------------------
Microfocus Cobol batch run
  Started: Fri Feb  5 01:53:06 GMT 2010
 => System wms
 => Program WMPICSLT
process not attached to terminal
Usage:  who [-rbtpludAasHTqRm] [am i] [utmp_like_file]
r       run level
b       boot time
t       time changes
p       processes other than getty or users
l       login processes
u       useful information
d       dead processes
A       accounting information
a       all (rbtpludA options)
s       short form of who (no time since last output or pid)
H       print header
T       status of tty (+ writable, - not writable, x exclusive open, ? hung)
q       quick who

Usage:  who [-rbtpludAasHTqRm] [am i] [utmp_like_file]
r       run level
b       boot time
t       time changes
p       processes other than getty or users
l       login processes
u       useful information
d       dead processes
A       accounting information
a       all (rbtpludA options)
s       short form of who (no time since last output or pid)
H       print header
T       status of tty (+ writable, - not writable, x exclusive open, ? hung)
q       quick who
R       print host name
Run completed with return code: 0
Microfocus Cobol Batch Run Ending : Fri Feb  5 01:53:50 GMT 2010
pic-selection @ending successfully on Fri Feb 5 01:53:50 GMT 2010

This job is suppose to email reports to user, however user is not receiving required reports.

How to over come this error.

can you please post the script which you are trying to run..

The error messages is coming from a "who" command which needs a terminal.

e.g.
who am i

When running in background there is no terminal.

Your script may need a rethink to run in background.

e.g.
if [ -t 0 ]
then
           echo "Script is in foreground"
           who am i
else
           echo "Script is in background"
fi

Hi

Here is the entire code

#!/bin/ksh 
#!/bin/ksh -x
#===============================================================================
#
#  DESC:   SCRIPT TO EMAIL AN COBOL REPORT TO A USER
#
#===============================================================================
# DETERMINE USER ID
#===============================================================================
#
if [ -z "$USER" ]
then
   USER=`who am i|cut -f1 -d" "`
   if [ -z "$USER" ]
   then
      USER=oramgr
   fi
fi
USERID=`cat /etc/passwd|grep ^$USER:|cut -d: -f3`
if [ -z "$USERID" ]
then
   USERID=$USER
fi
#
#===============================================================================
# SET VARIABLES
#===============================================================================
#
TIMESTAMP=`date +%C%y%m%d%H%M%S`
EXPAND_FILE=/$APSYSTEM/tmp/$1.$USERID.$TIMESTAMP
EMAIL_FILE=/$APSYSTEM/tmp/email/$1.$USERID.$TIMESTAMP
EMAIL_DEST=/$COBUSR/scripts/email.report.dests
HOST=`uname -n`
#
#===============================================================================
# EXPAND REPORT, I.E. REPLACE TABS WITH SPACES, AND CONVERT CR & FF TO LF
#===============================================================================
#
expand $2 > $EXPAND_FILE
tr "\015" " " < $EXPAND_FILE > $EMAIL_FILE
rm -f $EXPAND_FILE
mv $EMAIL_FILE $EXPAND_FILE
cat $EXPAND_FILE | sed 's/$/\\par /g' > $EMAIL_FILE
rm -f $EXPAND_FILE
mv $EMAIL_FILE $EXPAND_FILE
cat $EXPAND_FILE | sed 's/^/~/g' > $EMAIL_FILE
rm -f $EXPAND_FILE
mv $EMAIL_FILE $EXPAND_FILE
#
#===============================================================================
# READ ENTIRE FILE AND INSERT PAGE BREAKS EVERY 66 LINES
#===============================================================================
#
LNE=0
while read -r data
do
   let LNE=LNE+1
   if [ $LNE -eq 66 ]
   then
      echo "$data \\page" >> $EMAIL_FILE
      LNE=0
   else 
      echo "$data" >> $EMAIL_FILE
   fi 
done < $EXPAND_FILE
mv $EMAIL_FILE $EXPAND_FILE
cat $EXPAND_FILE | sed 's/^~//g' > $EMAIL_FILE
rm -f $EXPAND_FILE
mv $EMAIL_FILE $EXPAND_FILE
#
#===============================================================================
# WRITE MIME HEADER
#===============================================================================
#
echo "Mime-Version: 1.0" > $EMAIL_FILE
echo "From: $HOST" >> $EMAIL_FILE
echo "Subject: Report: $1" >> $EMAIL_FILE
echo "Content-type: application/rtf;" >> $EMAIL_FILE
echo "        name=$1.rtf" >> $EMAIL_FILE
echo "Content-Disposition: attachment; name="'"'$1".rtf"'"' >> $EMAIL_FILE
echo "Content-Description: Rich Text Format" >> $EMAIL_FILE
echo "" >> $EMAIL_FILE
#
#===============================================================================
# WRITE RTF HEADER
#===============================================================================
#
echo '{\\rtf1\\ansi\\def0\deftab720' >> $EMAIL_FILE
echo '{\\colortbl;\\red0\\green0\\blue0;}' >> $EMAIL_FILE
echo '{\\fonttbl{\\f0\\fmodern\\fprq1 Courier New;}}' >> $EMAIL_FILE
echo '\\paperw16840\\paperh11907\\margl851\\margr851\\margt567\\margb567' >> $EMAIL_FILE
echo '\\sectd \\lndscpsxn\\psz9\\linex0\\headery709\\footery709\\colsx709' >> $EMAIL_FILE
echo '\\pard\\plain\\b\\f0\\fs14 ' >> $EMAIL_FILE
#
#===============================================================================
# WRITE PLACE FILE IN STREAM HEADER
#===============================================================================
#
cat $EXPAND_FILE >> $EMAIL_FILE
rm -f $EXPAND_FILE
echo "}" >> $EMAIL_FILE
#
#===============================================================================
# DETERMINE WHO TO SEND TO & SEND IT
#===============================================================================
#
SENT=0
cat $EMAIL_DEST|grep "^$1#"|
while read dests
do
   EMAIL_ACCOUNT=`echo $dests|cut -f2 -d" "`
   #echo $EMAIL_ACCOUNT
   mail $EMAIL_ACCOUNT < $EMAIL_FILE
   SENT=1
done
#
#===============================================================================
# CHECK IF EMAIL SENT, IF NOT, SEND IT WAYNE WITH ERROR MESSAGE
#===============================================================================
#
if [ "$SENT" -eq 0 ]
then
mail xxx@co.uk < $EMAIL_FILE   
fi

The error message is coming from:

First reaction would be to seed $USER just before this line if we are in background.

# Set default user if we are in background.
if [ ! -t 0 ]
then
       USER="oramgr"
fi

Obviously this script has never been run in background so there may be other issues.