1

I've got a series of production servers that I'd like to be able to run certain utilities on without having to SSH into the machine.

Unfortunately, some of those programs (top and iotop I've tried so far) require curses and/or a TERM environment variable to be set, and executing from the shell via SSH doesn't work:

$ ssh myserver top
TERM environment variable not set.
$ ssh myserver iotop
Traceback (most recent call last):
  File "/usr/sbin/iotop", line 16, in <module>
    main()
  File "/usr/lib/python2.7/dist-packages/iotop/ui.py", line 571, in main
    main_loop()
  File "/usr/lib/python2.7/dist-packages/iotop/ui.py", line 561, in <lambda>
    main_loop = lambda: run_iotop(options)
  File "/usr/lib/python2.7/dist-packages/iotop/ui.py", line 465, in run_iotop
    return curses.wrapper(run_iotop_window, options)
  File "/usr/lib/python2.7/curses/wrapper.py", line 22, in wrapper
    stdscr = curses.initscr()
  File "/usr/lib/python2.7/curses/__init__.py", line 33, in initscr
    fd=_sys.__stdout__.fileno())
_curses.error: setupterm: could not find terminal

Any tips? Is this possible?

spitzanator
  • 113
  • 5

2 Answers2

6

You say you want to run them without ssh, yet you connect over ssh. This makes very little sense :)

I'll assume you want to run utilities over ssh without starting a shell. That's possible, just make ssh allocate a PTY for you even if it doesn't start a shell:

ssh -t myserver top
Dennis Kaarsemaker
  • 18,793
  • 2
  • 43
  • 69
1

For "top" you can use the "batch mode" - many tools have this too:

ssh myhost top -bn1
Pascal Schmiel
  • 1,728
  • 12
  • 17