Sample Header Ad - 728x90

How to prevent tabulated outputs of functons being messed up when using 'watch' over ssh?

0 votes
0 answers
96 views
While ssh-ing into my server I want to be able to monitor for activity over certain port using netstat. Instead of running it manually I want to automate it with watch. While the command (sudo netstat -apon | grep 44002) running by itself gives the right output tcp 0 0 127.0.0.1:44002 0.0.0.0:* LISTEN 1750/sshd: mainuser off (0.00/0/0) tcp6 0 0 ::1:44002 :::* LISTEN 1750/sshd: mainuser off (0.00/0/0) when combined with watch the output gets garbled looking roughly like: tcp 0 0.0.0.0:* LISTEN 1 c2-user off (0.00/0/0) tcp6 c2-user off (0.00/0/0) 0 ::1:44002 I suspect this has something to do with the witdh of the terminal not being handled properly. How can I fix this?
Asked by KubaFYI (113 rep)
Dec 12, 2019, 12:00 PM