Results 1 to 3 of 3
Hi all,
I've been trying to use both ssh and watch commands in the same line, but getting this error:
Error opening terminal: unknown.
I'm typing the following command:
Code:
...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 08-20-2011 #1Just Joined!
- Join Date
- Feb 2010
- Posts
- 2
Using ssh command with watch
Hi all,
I've been trying to use both ssh and watch commands in the same line, but getting this error:
I'm typing the following command:Error opening terminal: unknown.
Can anyone help shed some light if it's possible to use both commands?Code:mSergani:~ $ ssh user.at.192.168.1.100 "watch df -h"
It's highly important in my line of work.
Thanks.
//M
- 08-23-2011 #2Trusted Penguin
- Join Date
- May 2011
- Posts
- 3,657
The watch command is meant to run in a terminal indefinitely, but your ssh command will just log in, run the command, and exit the shell (terminal). If you truly want the df command to run indefinitely, you should look into screen, which will keep a dedicated terminal open for watch to use.
Or, you could run your df command on the remote machine in an indefinite loop, and redirect (append or overwrite) the output to a file, which you could then ssh in and read.
Or, you could do the loop on the client/ssh side: in an indefinite loop, you could ssh in and grab the output of df, then log out:
Code:#!/bin/sh while :; do ssh "df -h" sleep 2 done
- 08-23-2011 #3Just Joined!
- Join Date
- Feb 2010
- Posts
- 2
I was able to do the task with the -t option

Also your method will not help me that much, as I have scripts running on the remote server monitoring for logins, and would immediately dispatch an email for the whole team about the new connection.Code:mSergani:~ $ ssh -t user.at.192.168.1.100 "watch df -h"
Thanks for the help though


Reply With Quote
