Go Back   HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials > Linux Forums > Programming/Scripts

Do you like HowtoForge? Please consider supporting us by becoming a subscriber.
Reply
 
Thread Tools Display Modes
  #1  
Old 24th August 2011, 06:50
waiwai waiwai is offline
Junior Member
 
Join Date: Aug 2011
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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
do
#read hostname
#read line
num=0
ssh -t -t ${line} < cmd > test2.txt
num=1
if [ $num -eq 1 ]
then
ssh -t -t ${line} < cmd >> test2.txt
fi
done
echo "done"
exit 0
the code is work fine. but I'm kinda dissapointed on the results. I got what I wan but just too much.

[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.
Reply With Quote
Sponsored Links
  #2  
Old 24th August 2011, 14:20
Mark_NL Mark_NL is offline
Senior Member
 
Join Date: Sep 2008
Location: The Netherlands
Posts: 912
Thanks: 12
Thanked 100 Times in 96 Posts
 
Default

Code:
ssh -q <server> "hostname; uname -a"
Reply With Quote
Reply

Bookmarks

Tags
shell script, ssh

Thread Tools
Display Modes

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 On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
DNS Lookups kieron General 4 4th May 2011 19:49
cannot create new ssh users for one client wildnux Server Operation 0 9th February 2011 01:10
Client initiated backups of site data and db? jbryner General 0 4th July 2009 20:14
Apache2 server stopped working and fails restart without error chillifire Installation/Configuration 3 13th March 2008 16:26
Help with Bluetooth PAND josto HOWTO-Related Questions 1 7th August 2007 20:53


All times are GMT +2. The time now is 05:24.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.