LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 03-12-2014, 02:54 AM   #1
anandrhce
LQ Newbie
 
Registered: Feb 2007
Posts: 17

Rep: Reputation: 0
Script for SerialNumber - ServerName


Can someone help to get the expected output:

Script:
for i in `cat a`; do ssh -q $i -t " /usr/bin/sudo /usr/sbin/dmidecode -s system-serial-number;hostname" ; done

Current Output:

SerialNumber
ServerName


Expected Output:

SerialNumber - ServerName
 
Old 03-12-2014, 06:55 AM   #2
Ser Olmy
Senior Member
 
Registered: Jan 2012
Distribution: Slackware
Posts: 3,348

Rep: Reputation: Disabled
I assume that by "expected output" you mean "desired output", as the script does exactly what it's supposed to do. It runs two separate commands, and the output from each appears on a separate line.

How about piping the output from dmidecode through tr and have it replace the newline character with a space?
Code:
for i in `cat a`; do ssh -q $i -t "/usr/bin/sudo /usr/sbin/dmidecode -s system-serial-number | tr '\n' ' ' ; hostname" ; done
This will cause the output from the dmidecode and hostname commands to appear on the same line.
 
1 members found this post helpful.
Old 03-12-2014, 07:28 AM   #3
anandrhce
LQ Newbie
 
Registered: Feb 2007
Posts: 17

Original Poster
Rep: Reputation: 0
Resolved

Ser Olmy Thanks a lot... That works like a gem..
 
Old 03-12-2014, 07:37 AM   #4
allend
LQ 5k Club
 
Registered: Oct 2003
Location: Melbourne
Distribution: Slackware64-15.0
Posts: 6,485

Rep: Reputation: 2807Reputation: 2807Reputation: 2807Reputation: 2807Reputation: 2807Reputation: 2807Reputation: 2807Reputation: 2807Reputation: 2807Reputation: 2807Reputation: 2807
You could also do
Code:
for i in `cat a`; do ssh -q $i -t ' /usr/bin/sudo echo "$(/usr/sbin/dmidecode -s system-serial-number) $(/bin/hostname)" '; done
 
  


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
Automount works with IP, not with servername. madspikes Linux - General 1 01-28-2008 05:47 PM
Apache ServerName Matir Linux - Software 2 08-12-2005 10:18 PM
can't ping Apache by ServerName semesm Linux - Newbie 1 05-13-2004 05:32 PM
apache servername agfaread Linux - Newbie 0 07-01-2003 02:47 AM
appache servername illtbagu Linux - Software 8 02-26-2003 11:28 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 04:34 PM.

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