Formatting Script Output


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Formatting Script Output
# 1  
Old 08-05-2007
Formatting Script Output

Hello all,

Can somebody please offer some advice. I'm working on a small script to list all packages on the local and remote systems and need it in the following format.

Machine Name, Package, Version

Here is what i have so far but i can't seem to get the output of the hostname to loop to the eof and in the correct format.

#!/usr/bin/sh
hostname=`uname -n`

echo "SERVERNAME:" $hostname
echo "===================="
for i in *
do
tmp=echo `hostname`
done

plist=`pkginfo | grep 'E[CN]' | grep -v 'Oraaixc' | grep -v 'VZcsgwevc' | grep -
v 'VZcsgwevs' | awk 'BEGIN {OFS=","}\
{gsub(/version:/,"");}{print $2,$7}'`

print "$tmp" "$plist"

The output from the plist is correct but can't get the hostname portion correctly.

Your feedback is greatly appreciated

Thanks,
# 2  
Old 08-06-2007
Try:
Code:
tmp=$(hostname)

# 3  
Old 08-06-2007
It should have been like

Code:
tmp=`echo $hostname`

or
Code:
tmp=$hostname

# 4  
Old 08-06-2007
TY for the response. They both worked and put in the hostname. But what i wanted to acheive was really this. I wanted the script to output the hostname for every package output listed in the grep. So if the grep found say 5 packages it would list the hostname 5 times.

ie

machinename,packagename,version
machinename,packagename,version
machinename,packagename,version
machinename,packagename,version
machinename,packagename,version

In this kinda format. I just can't figure it out with the for loop.

Thanks for all your help
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk Script Output in Outlook Formatting Issue

When i execute the below shell script with 2 different Input files, for one of the data files (datafile1) my email message body in the outlook messes up and every thing comes up in one line. May i please know what i am doing wrong here or how to fix this? The only difference in data files is one is... (1 Reply)
Discussion started by: Ariean
1 Replies

2. Shell Programming and Scripting

SQL Query in Shell Script output formatting

Hi All, #!/bin/ksh call_sql () { sql=$1 sqlplus -s $sqlparam_sieb <<EOF SET ECHO OFF; SET NEWPAGE NONE; SET SQLBL OFF; SET VERIFY OFF; SET LINESIZE 2000; SET... (2 Replies)
Discussion started by: Kevin Tivoli
2 Replies

3. Shell Programming and Scripting

Formatting output of script

I'm looking for a way to neaten up the out put of an ldapquery. I might get one, none, or several returns for each query; and each query consists of multiple lines. And while each return will contain the same types of info, it might be in a different order, like: uniq: 1 ip: 192.168.2.3... (3 Replies)
Discussion started by: jnojr
3 Replies

4. Shell Programming and Scripting

Formatting Shell script output to Excel

I am facing a problem formatting the output of my shell script in excel. We are directing the output of the script to an excel sheet and need long integer type data printed in Excel as it is (i.e. not in the default scientific notation). Also, leading zeroes(if any) in the output are getting... (4 Replies)
Discussion started by: bornali.p
4 Replies

5. Shell Programming and Scripting

Problem in formatting output of SQL query in excel sheet in shell script

Hi Guys.. Need your help to format the output of my shell script. I am using spool command to take out put in csv file. below is my code. (for example) col USERNAME for a15 col EMAIL for a30 col FULL_NAME for a20 col LAST_LOGIN for a40 col DATE_CREATED for a40 SPOOL 120.csv... (3 Replies)
Discussion started by: Agupte
3 Replies

6. Shell Programming and Scripting

Need help with output formatting

Hey can anyone help me with newline formatting? i bet someone will ask why im rewriting du code, im trying to write a simple script that have slightly different function than du lol.... echo $(du "$dval" | tr ' ' '\n') atm with above code it will printout i've tried sed and awk... cant... (7 Replies)
Discussion started by: Nick1097
7 Replies

7. Shell Programming and Scripting

sql select command output formatting in shell script

Hi, I need to connect to the database and retrieve two variables from the database and store them in a variable,out of these two variables I need to get lastdigit appended to the variable 1 retrieved and variable 2 with out any modification in short select var,data from usage; o/p=... (1 Reply)
Discussion started by: rkrish
1 Replies

8. Shell Programming and Scripting

Formatting the query output using shell script

Hi All, I'm finding it difficult to format the query output that was returned in a shell script. Actually i have one shell script which does some DB stuff and depending on the result it will do some more tasks. My question here is to format the query output returned by mysql. Intitally my... (5 Replies)
Discussion started by: RSC1985
5 Replies

9. Shell Programming and Scripting

Formatting Sar Output script

Hi, We have 2 scripts below for reporting sar output which are pretty same. In first script i want to add to the program whatever is given in the comments. In second script I want to use while true to run this program every hour and everything that is in comment. Finally I want to club... (0 Replies)
Discussion started by: noorm
0 Replies

10. Shell Programming and Scripting

Formatting the output of a script

Dear readers, I have a script that counts the number of files in particular directories in my home location and displays the output. Now I have 13 directories in my home location. I am getting the output as : Avishek_dir 13 Kunal_dir 17 Shantanu_dir 18 Arup_dir 12 Pranabesh_dir 19 . .... (7 Replies)
Discussion started by: avishek007
7 Replies
Login or Register to Ask a Question