LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-21-2007, 01:24 AM   #1
vikas027
Senior Member
 
Registered: May 2007
Location: Sydney
Distribution: RHEL, CentOS, Ubuntu, Debian, OS X
Posts: 1,305

Rep: Reputation: 107Reputation: 107
Question top command not found while using ssh


hi i was trying to ssh on a remote server through command line

however, top command is not running in it. Im using Sun OS

ssh IP " top -d1 " > output;

any clue,
however ssh IP "df -k" > output works fine

im getting this error.
sh: top: not found

Thanks in adv.
 
Old 10-21-2007, 02:13 AM   #2
angrybanana
Member
 
Registered: Oct 2003
Distribution: Archlinux
Posts: 147

Rep: Reputation: 21
Sounds like the machine doesn't have the top command installed, or it's in a dir thats not in PATH.
 
Old 10-21-2007, 02:54 AM   #3
vikas027
Senior Member
 
Registered: May 2007
Location: Sydney
Distribution: RHEL, CentOS, Ubuntu, Debian, OS X
Posts: 1,305

Original Poster
Rep: Reputation: 107Reputation: 107
Angry

Quote:
Originally Posted by angrybanana View Post
Sounds like the machine doesn't have the top command installed, or it's in a dir thats not in PATH.
no friend, top commands works absolutely fine on prompt. The thing is that it is not working in a script.
Its like
top -d1 > file is working

but

ssh -l root IP "top -d1" > file is not working.
 
Old 10-21-2007, 04:06 AM   #4
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 65
Try:
Code:
ssh remotehost top -bn1 > output
The reason that it doesn't work is that if top is outputting to a terminal (normal operation), it uses the curses library to perform operations such as setting bold/inverse video fonts, moving the cursor etc.

These operations have no meaning when re-directing output to a file, and so curses does not work (complaints about the TERM variable). Using the -b option tells top to print in a way which is OK for re-direction.

Last edited by matthewg42; 10-21-2007 at 04:10 AM.
 
Old 10-21-2007, 09:52 AM   #5
vikas027
Senior Member
 
Registered: May 2007
Location: Sydney
Distribution: RHEL, CentOS, Ubuntu, Debian, OS X
Posts: 1,305

Original Poster
Rep: Reputation: 107Reputation: 107
Thumbs up

Quote:
Originally Posted by matthewg42 View Post
Try:
Code:
ssh remotehost top -bn1 > output
The reason that it doesn't work is that if top is outputting to a terminal (normal operation), it uses the curses library to perform operations such as setting bold/inverse video fonts, moving the cursor etc.

These operations have no meaning when re-directing output to a file, and so curses does not work (complaints about the TERM variable). Using the -b option tells top to print in a way which is OK for re-direction.

THANK YOU SO MUCH FOR THE COMMAND AND INFO AS WELL, WORKING WELL NOW.
 
Old 10-23-2007, 08:44 AM   #6
vikas027
Senior Member
 
Registered: May 2007
Location: Sydney
Distribution: RHEL, CentOS, Ubuntu, Debian, OS X
Posts: 1,305

Original Poster
Rep: Reputation: 107Reputation: 107
Unhappy

Quote:
Originally Posted by vikas027 View Post
THANK YOU SO MUCH FOR THE COMMAND AND INFO AS WELL, WORKING WELL NOW.

hey again, this works absolutely fine for Linux Machines, but in Solaris Machines i am getting error.
 
Old 10-23-2007, 09:01 AM   #7
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 65
Check the manual page in the Solaris machine and see if there is a similar option for the version of top which installed there. I seem to have some memory from an old sunos4 machine which I worked on that it does, but I do not recall what it is.
 
Old 10-23-2007, 09:07 AM   #8
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 65
Another thought - maybe the Solaris machines do not support option clustering. I also found a manual page on the net which said -n was an alias to -b, so try them separately. Try each of these and see if they help:
Code:
ssh remotehost top -b -n 1 > output
ssh remotehost top -b > output
ssh remotehost top -n > output
 
Old 10-24-2007, 07:29 AM   #9
vikas027
Senior Member
 
Registered: May 2007
Location: Sydney
Distribution: RHEL, CentOS, Ubuntu, Debian, OS X
Posts: 1,305

Original Poster
Rep: Reputation: 107Reputation: 107
THANKS TO ALL, ssh IP "/usr/bin/top -b -n1" works well on solaris as well as linux machines.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
top command Volcano Programming 18 10-15-2008 10:02 PM
Top command mtnpaul Linux - Software 2 04-17-2008 04:25 AM
Top Command swamprat Linux - Software 3 09-23-2007 02:08 AM
bash: rpm: command not found && sudo: alien: command not found Java_Code Ubuntu 7 07-27-2006 11:57 PM
command top getting error bluenectar Linux - General 2 08-19-2005 09:37 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:28 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration