Quote:
Originally Posted by
Ariean
sorry i couldn't able to comprehend what you are saying, i checked the manual page for tty it's just saying it return's user terminal name. I am confused when you say "teriminal down" where & when we will you use tty??, also can you please interpret me in layman standard what's happening in the below script, what i should do to make it work in k shell, appreciate your help.
Thanks a lot for all your replies.
1) Move your ttyname= line to the bottom, and add ' 2>&1' just before ')'.
2) Just under that, say: if [ "$ttyname" != "not a tty" ] ; then interactive-stuff . . . fi
3) Start moving things a script either does not need, or can not run, down into that if block, like:
HIST*= variables (scripts do now write .sh_history or can inherit this)
EDITOR=vi; export EDITOR (scripts do not edit the command history or can inherit this)
TERM=
PS*= (shell scripts do not prompt the user or can inherit this)
tput (there is no t to put to)
set -o vi (a .profile needs to be sh friendly, which means no {set -o, $() ${#%}, export var=val }, but this is ksh only, so put it at the very bottom of the interactive block, and devise how to ensure it is run by ksh, say if [ `ps -p $$ | grep -c ksh` = 1 ]; then ksh-directives . . . fi)
I do not know if other env vars are interactive-support-only, but you should. Setting excess env vars is not a big deal, but once you have a place for a thing, put it in the right place.
Ensuring SHELL= is set is nice, for not-necessarily-interactive things like starting an xterm, as well as any shell-out from a command.
Then, the .profile stops short if called from cron, ssh/ssh2/rsh, nohup after the starting terminal hangs up, etc. Also, ksh-specific things do not run under sh.