Process not attached to terminal


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Process not attached to terminal
# 1  
Old 02-05-2010
Process not attached to terminal

Hi Folks,

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

Code:
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.

Last edited by pludi; 02-05-2010 at 04:09 AM.. Reason: code tags, please...
# 2  
Old 02-05-2010
can you please post the script which you are trying to run..
# 3  
Old 02-05-2010
The error messages is coming from a "who" command which needs a terminal.
Code:
e.g.
who am i

When running in background there is no terminal.

Your script may need a rethink to run in background.
Code:
e.g.
if [ -t 0 ]
then
           echo "Script is in foreground"
           who am i
else
           echo "Script is in background"
fi

# 4  
Old 02-09-2010
Hi

Here is the entire code

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


Last edited by vbe; 02-09-2010 at 09:52 AM.. Reason: please use code tags!
# 5  
Old 02-09-2010
The error message is coming from:

Quote:
if [ -z "$USER" ]
then
USER=`who am i|cut -f1 -d" "`
if [ -z "$USER" ]
then
USER=oramgr
fi
fi
First reaction would be to seed $USER just before this line if we are in background.

Code:
# 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.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. AIX

Process on a specified Terminal and Socket Port does not start

Hi, I new to AIX, and I have been using Rocket UniData in it. I had to set up a Process for Data Exchange by assigning a unique Terminal and a Socket Port to that process. I ran the process for the first time and it was successful and after use I stopped the process. Now when I want to run it... (3 Replies)
Discussion started by: BejoyS
3 Replies

2. Shell Programming and Scripting

Print Terminal Output Exactly how it Appears in the Terminal to a New Text File

Hello All, I have a text file containing output from a command that contains lots of escape/control characters that when viewed using vi or view, looks like jibberish. But when viewed using the cat command the output is formatted properly. Is there any way to take the output from the cat... (7 Replies)
Discussion started by: mrm5102
7 Replies

3. UNIX for Advanced & Expert Users

Getting the process ID of the terminal in Unix/Linux

Hi, How can we get the process id of the terminal we are using? When we logged in to unix, we have an associated terminal. we can use "tty" command to get the terminal we are using like: /dev/pts/0 I want to know the process id of this terminal. Please reply as I searched a lot but I... (8 Replies)
Discussion started by: crazybisu
8 Replies

4. Shell Programming and Scripting

need to extract terminal from this process -perl regx

Hi All, i ve a process, user4 31779 2836 0 01:43 pts/6 00:00:00 sh /home/user/DATE/SUT_SCR/c.sh like this i'll get so many process when in run ps -ef | grep pts | grep c.sh i need to extract terminal id from this string. i.e pts/6, or sometimes pts/22 same way i need to do for... (3 Replies)
Discussion started by: asak
3 Replies

5. Shell Programming and Scripting

shell script to kill process with respect to terminal

Hi, I've a script which kills all process, but i need a script shell script(sh), where it'll kill process on that particular terminal. below is example TY=`tty` for P in $TY do `kill -9 $P 2>/dev/null`; done echo "test process killed" break ... (3 Replies)
Discussion started by: asak
3 Replies

6. Shell Programming and Scripting

Process behavior different when spawned from single terminal

So this one just plain confuses me. I have a bunch of somewhat CPU intensive processes that all communicate using a shared memory region. Some of these programs are threaded and some also change the scheduling to FIFO or round robin. The good news is that everything works as long as I spawn... (3 Replies)
Discussion started by: talkingfennel
3 Replies

7. Solaris

Start process independent from TERMINAL (or also with PPID 1)

Hi *, please, I need fast tip (help). I have a process starting through /etc/rc3.d/xxxx script. However, sometimes (mostly because of testing reasons) I need to stop the process, change something and then start it again. But: 1) when I start it in terminal, the process dies when I leave the... (2 Replies)
Discussion started by: freeangel
2 Replies

8. UNIX for Advanced & Expert Users

Control process from different terminal (over SSH)

I pressed CTRL Z and suspended the job. then I pressed bg, The process re-started to throw output on the terminal and its not allowing me to access the prompt. its not even accepting CTRL Z. The process has been running for about 2 hours now and I want to suspend it by opening another terminal.... (3 Replies)
Discussion started by: rakeshou
3 Replies

9. UNIX for Advanced & Expert Users

how to run a process after closing the terminal

i want to execute a shell script even if the terminal is closed. how to do? (3 Replies)
Discussion started by: lakshmananindia
3 Replies

10. Shell Programming and Scripting

Start process in shellscript at other terminal

A programming running in tty0 crashes. In a second terminal I kill all the processes. Can i start the program again from this terminal? Yes, I can, but it starts in tty1, and when i close the terminal, the program closes. Now I want to start the program from tty1 in tty0, so i can close... (4 Replies)
Discussion started by: benschell
4 Replies
Login or Register to Ask a Question