Shell script for using yum command

Hi,

I want to downgrade or uninstall a package using yum, say Samba in rhel 6. All I want to write a shell script that is use to downgrade or uninstall that package using yum.

Can anyone please help me out?

Thanks in Advance

Why do you need a script? Did you consult the man pages.

yum remove package
yum erase package
yum downgrade package

Actually I want to uninstall/install a package using yum through shell scripting.
I tried using the above mentioned command but didn't work for me.
can you please send a proper code written in shell scripting?
I'll be highly thankful for your cooperation.

If the command doesn't work from the command line, it's not likely to work from a script. Post the error you got.

It is working fine from command line
but not from script.

That tells us nothing useful. We could guess all day at millions of things that might keep a script from working, but the chances that any of them would solve your problem are probably less than 1 in a billion.

  1. Show us the exact commands you are using on the command line that work (in CODE tags).
  2. Show us the exact contents of your shell script (in CODE tags).
  3. Show us exactly how you invoke your shell script (in CODE tags).
  4. Show us the exact output (including any diagnostic messages) produced by your shell script (in CODE tags).

With that information, we stand a MUCH better chance of being able to make suggestions that might help you resolve your problem.

The error I'm facing is:

[root localhost Desktop]# ./remov.sh
bash: ./remov.sh: /bin/sh^M: bad interpreter: No such file or directory
[root localhost Desktop]# ]

I'm trying to run :

[root localhost Desktop]# yum remove -y samba

The content of my .sh file :

#!/bin/sh
#yum remove -y samba

Please use CODE TAGS for code or terminal output as you agreed by the forum rules.

The ^M sounds like a Windows->Unix linebreak issue.
And your script has the 'yum' line as comment, and therefor will not work.

hth