LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-27-2010, 01:30 PM   #1
macking
LQ Newbie
 
Registered: May 2010
Posts: 27

Rep: Reputation: 0
Yum update script with return value


I am trying to automate yum update of specific package on a remote machine.

So far I have this:


#!/bin/bash
# Update my system
if ! yum update w3m
then
failure=1
fi
if [ $failure ]
then
echo "Could not update system." >&2
exit 1
fi
echo "Update successful"
exit 0


The script runs fine and shows:

Loading "installonlyn" plugin
Loading "security" plugin
Loading "rhnplugin" plugin
This system is not registered with RHN.
RHN support will be disabled.
Setting up Update Process
Setting up repositories
Reading repository metadata in from local files
Skipping security plugin, no data
Could not find update match for w3m
No Packages marked for Update/Obsoletion
Update successful


This is OK, but I NEED it to just return the final echo "Update successful".

How can I do this?

Thanks for all the help!
 
Old 07-27-2010, 01:56 PM   #2
AwesomeMachine
LQ Guru
 
Registered: Jan 2005
Location: USA and Italy
Distribution: Debian testing/sid; OpenSuSE; Fedora; Mint
Posts: 5,524

Rep: Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015
This would be less trouble:

#!/bin/bash
# Update my system

if [ "yum -y install w3m | grep 'already installed'" -ne null]
then
echo "Could not update system." >&2
exit 1
else
echo "Update successful"
exit 0
echo "Repository not available."

Last edited by AwesomeMachine; 07-27-2010 at 01:57 PM.
 
Old 07-27-2010, 02:17 PM   #3
macking
LQ Newbie
 
Registered: May 2010
Posts: 27

Original Poster
Rep: Reputation: 0
The script should be installing the update. If the install it fails it would say could not update system, if it installs the update or it isn't necessary it would echo update successful.

I can't have any other text appearing though. That's the hard part.

Not familiar with how to use stdout on the first section and then revert back to echo success.
 
Old 07-29-2010, 02:57 PM   #4
macking
LQ Newbie
 
Registered: May 2010
Posts: 27

Original Poster
Rep: Reputation: 0
Does anybody have any idea on how to do this?
 
  


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
how to update rhel 5 using centos yum updater without conflict with yum redhat plugin udayvikram Linux - Software 2 03-30-2010 08:15 AM
how to update rhel 5 using centos yum updater without conflict with yum redhat plugin udayvikram Linux - Newbie 1 03-29-2010 12:56 PM
dpkg return error :post installation script return an error code (1) grimfold Debian 2 09-10-2009 01:55 PM
erased yum.conf by forced yum-update in RHEL5.3, need help curiocurio Red Hat 3 04-21-2009 03:33 AM
Query re: order of yum update and yum install jajtiii Linux - General 0 12-12-2005 12:48 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

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