Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

TERM problems

by hotshot (Prior)
on Sep 06, 2004 at 06:41 UTC ( #388737=perlquestion: print w/ replies, xml ) Need Help??
hotshot has asked for the wisdom of the Perl Monks concerning the following question:

Hi all!

I have a command line interface for my software that works perfectly fine when running from the computer it's installed on (Linux RH9.0). The program can work in shell mode if no arguments are supplied or can execute one command when arguments are given (as in the example).
When running from a client (other computer), it still works but outputs warning/error to the console:
# running from the computer it's installed on: prompt> su - user -c "myprog exports view" These are the current defined exports: Index Status Export 0 active /TestDir (insecure,rw) 1 active / (insecure,rw) # running from the client machine: client prompt> rsh mycomp "myprog exports view" No value for $TERM and no -T specified No value for $TERM and no -T specified These are the current defined exports: Index Status Export 0 active /TestDir (insecure,rw) 1 active / (insecure,rw)
Anyone has an idea what that means?

Thanks

Comment on TERM problems
Download Code
Re: TERM problems
by saintmike (Vicar) on Sep 06, 2004 at 07:15 UTC
    Every program running on Unix can check if its input/output is connected to a tty or not. In Perl, this is done via
    if(-t STDOUT) { print "tty\n"; } else { print "no tty\n"; }
    If you run this program from the command line, it'll print tty. If you run it via a remote shell on another host, you'll see no tty.

    I suspect your program is checking this and prints an error if it finds out about it.

      I added your test in the begining of myprog and as you said it printed tty when running from the localhost and no tty when running from the remote host, but I have no other test for it that can print the error I get. What can cause the error (maybe perl checks this)?

        It's not an error, it's a warning. rsh is insecure anyway. Why not use ssh which will work fine (see the -t and -T options) .....

        ssh -t some.host.com <command>

        cheers

        tachyon

Re: TERM problems
by trantor (Chaplain) on Sep 06, 2004 at 10:17 UTC

    It looks like this error is output by the tput program,

    try:

    unset TERM ; tput

    Perhaps tput is used somewhere in your initialisation scripts, or executed from your Perl script?

    It is quite likely that the $TERM environment variable is not propagated, con can verify with:

    rsh mycomp env

    As a side note, since rsh is known to be highly insecure, you should consider using ssh instead, i.e.:

    ssh -t mycomp env

    -t allocates a pseudo-tty (i.e. a terminal) even when it wouldn't normally be allocated by ssh.

      Hotshot, I had the same problem and discovered it was due to using colors in my bash prompt. I fixed it with a simple if check:
      if [ $TERM != "dumb" ];then export PS1=pretty_color_prompt fi
      Worked like a champ. Keep in mind the "clear" call is just a wrapper to tput. So check those dotfiles for any clear commands as well.
Re: TERM problems
by Anonymous Monk on Sep 23, 2004 at 14:55 UTC
    Heya Hotshot. I just had this problem due to adding colors to my PS1 prompt. I changed it to the following:
    if [ $TERM != "dumb" ];then export PS1=... fi
    I've also read tput can be called by the "clear" command, so check those dotfiles for clear! Hope this helps. :)

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://388737]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (6)
As of 2014-10-22 00:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (112 votes), past polls