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! |
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." |
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. |
Does anybody have any idea on how to do this?
|
All times are GMT -5. The time now is 01:58 PM. |