![]() |
Get data from client using SSH in shell script
Currently I have 1 server and 2 slaves, I wan to get hostname and version from slaves using SSH command.
Code:
while read line[RESULT]Welcome to Ubuntu 11.04 (GNU/Linux 2.6.38-8-generic i686) * Documentation: https://help.ubuntu.com/ 206 packages can be updated. 59 updates are security updates. Last login: Tue Aug 23 20:11:02 2011 from 10.0.0.1 echo hostname = `hostname` echo version = `uname -a` exit ^[]0;ccc@ubuntu: ~^Gccc@ubuntu:~$ echo hostname = `hostname` hostname = ubuntu ^[]0;ccc@ubuntu: ~^Gccc@ubuntu:~$ echo version = `uname -a` version = Linux ubuntu 2.6.38-8-generic #42-Ubuntu SMP Mon Apr 11 03:31:50 UT$ ^[]0;ccc@ubuntu: ~^Gccc@ubuntu:~$ exit logout Welcome to Ubuntu 11.04 (GNU/Linux 2.6.38-8-generic i686) * Documentation: https://help.ubuntu.com/ 206 packages can be updated. 59 updates are security updates. Last login: Tue Aug 23 20:13:59 2011 from 10.0.0.1 echo hostname = `hostname` echo version = `uname -a` exit ^[]0;ccc@ubuntu: ~^Gccc@ubuntu:~$ echo hostname = `hostname` hostname = ubuntu ^[]0;ccc@ubuntu: ~^Gccc@ubuntu:~$ echo version = `uname -a` version = Linux ubuntu 2.6.38-8-generic #42-Ubuntu SMP Mon Apr 11 03:31:50 UT$ ^[]0;ccc@ubuntu: ~^Gccc@ubuntu:~$ exit logout [/RESULT] How to display the data I wan?What I wan is only hostname and version. I wan to delete the Welcome to ubuntu, those echo stuff.. Thanks. |
Code:
ssh -q <server> "hostname; uname -a" |
| All times are GMT +2. The time now is 00:11. |
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2013, vBulletin Solutions, Inc.