Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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

2 Answers 2

up vote 5 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:

"TERM=$TERM COLUMNS=$COLUMNS LINES=$LINES watch -n 1 top -bn 1
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

 
discard

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.