LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
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 04-20-2009, 10:45 AM   #1
learnerlearner
LQ Newbie
 
Registered: Apr 2009
Posts: 6

Rep: Reputation: 0
Need help with script comparing RPMs


Hi everyone...
I have a script for comparing RPMs installed as below:

#!/bin/bash -vx
##VARIABLES used below are defined in my profile and am importing them before i use them
rm -f list.log
#Extract the RPMs from RPM Database on each of the server (there are around 20 servers)
for i in $SERVER; do
echo -n "$i" >> list.log
echo "" >> list.log
ssh $i 'rpm -qa | grep '$CURRENT_VER' ' >> list.log
done

#Extract Info from the Delivery Server (this is the master server from where i take the RPMs for installing on other servers)
rm -f $DELIVERY_LOG
for j in $WEBDAV_SERVER; do
echo $DELIVER_DIR
ssh <user_name>@$j 'find '$DELIVER_DIR' -type f -name "vst3*.rpm" -printf %f\\n ' >> $DELIVERY_LOG
done

#Now, i get two files list.log and $DELIVERY_LOG. And here is what i am finding the problem.
# Compare the files delivery and list two get the difference.
Now here is what i am facing the problem.
1. I need to sort the $DELIVERY_LOG taking only higher version of the RPM and make it $FINAL_LOG
2. I need to compare $FINAL_LOG with the list.log and i should get the output as below
the RPM in $FINAL_LOG is missing on the server *$i
Will i have to create a property file which has which all RPMs are present on each server first? or is there any other method

i am a newbee to linux scripting....Could anyone help me out in this
 
Old 04-20-2009, 11:06 AM   #2
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
welcome to LQ!! This kind of thing needs to go into a new thread---you have jumped into an existing thread which is pretty much unrelated.

Reported to be moved...
 
Old 04-22-2009, 10:30 PM   #3
jtmoon
LQ Newbie
 
Registered: Jun 2006
Location: WA, USA
Distribution: Fedora Core 10
Posts: 16

Rep: Reputation: 5
Thumbs up while loop over piped-in lines of text.

Hi,
Here is the bash script code that should allow doing a
while loop over piped-in lines of text.

Code:
ls -1 "${MY_DIRECTORY}" | while read -e myLine ; do
  echo "The current line is '${myLine}'" ;
  # ...useful code goes here...
done
The key part is piping the output of ls -1 to while read -e .

Example output:
Code:
$ ls -1
bar
foo
foo bar

$ ls -1 | while read -e myLine ; do echo line is \'${myLine}\' ; done
line is 'bar'
line is 'foo'
line is 'foo bar'
-J_Tom_Moon_79
 
  


Reply



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
Comparing two files to get matched contents in another file using shell script pooppp Linux - Networking 3 08-05-2008 12:11 AM
script for updating rpms files (not installing them) ? rd1381 Linux - Software 5 02-14-2008 06:04 AM
comparing 2 strings in shell script dhanabalanb Programming 3 08-01-2007 01:17 PM
Shell script for comparing certain lines in two files mou5e Linux - Newbie 9 06-06-2007 01:40 PM
Comparing file sizes using a bash script. IanChristie Programming 5 12-19-2003 10:14 PM

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

All times are GMT -5. The time now is 10:57 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