Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a script:

export TERM=xterm
watch -t -d -n 1 'netstat -veeantpo | grep 43597

when we run this script though ssh, it does not determine the monitor resolution. so lines are wrapped although there is space to show results. You can see the result in the picture.(I have removed the trailing space after ESTABLISHED).

enter image description here

share|improve this question
up vote 6 down vote accepted

Add -t to your ssh. By default when you pass a command to ssh, it doesnt allocate a TTY on the remote host, so the application only has a basic STDOUT pipe to work with.

ssh -t foobar 'watch -t -d -n 1 "netstat -veeantpo | grep 43597"'
share|improve this answer

Your terminal info is not being passed on to the remote side. You can either tweak your SSH client and server config to pass the variables, or take the easy way and put them inside your command string:

share|improve this answer
because we ssh a lot to the server, I would prefer the first options. How we can configure ssh client and server to pass the variables? I am using openssh on debian 6 – Majid Azimi Mar 28 '12 at 12:04
Never mind my answer. The forced pseudo-tty allocation is much easier. – janmoesen Mar 29 '12 at 19:19

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.