Results 1 to 4 of 4
I need to create a shell script that will help me fix dkms drivers which failed to install.
it needs to contain the following lines:
dkms remove -m %{name} -v ...
- 08-01-2008 #1Just Joined!
- Join Date
- Jul 2008
- Posts
- 2
Shell Script for running 4 commands
I need to create a shell script that will help me fix dkms drivers which failed to install.
it needs to contain the following lines:
dkms remove -m %{name} -v %{version}-%{release} --rpm_safe_upgrade --all
dkms add -m %{name} -v %{version}-%{release} --rpm_safe_upgrade
dkms build -m %{name} -v %{version}-%{release} --rpm_safe_upgrade
dkms install -m %{name} -v %{version}-%{release} --rpm_safe_upgrade --force
I would like it to accept the variables and feed them into the appropriate places, is it possible to do ?
for example, lets say the file is called: dkms-repair
[root@localhost]# dkms-repair ndiswrapper 1.52
This will run the commands as follows:
dkms remove -m ndiswrapper -v 1.52 --rpm_safe_upgrade --all
dkms add -m ndiswrapper -v 1.52 --rpm_safe_upgrade
dkms build -m ndiswrapper -v 1.52 --rpm_safe_upgrade
dkms install -m ndiswrapper -v 1.52 --rpm_safe_upgrade --force
- 08-01-2008 #2Linux Guru
- Join Date
- Nov 2004
- Posts
- 6,110
You might find some interesting readinghere. The Advanced Bash Scripting guide is a great resource for anyone.
Here's a guess at some code off the top of my head, you will need to refine it more and test it yourselfIn the example above, $1 represents the first argument etc.Code:#!/bin/bash name=$1 version=$2 release=$3 dkms remove -m $name -v $version-$release --rpm_safe_upgrade --all dkms add -m $name -v $version-$release --rpm_safe_upgrade dkms build -m $name -v $version-$release --rpm_safe_upgrade dkms install -m $name -v $version-$release --rpm_safe_upgrade --force exit 0
This is just skeleton code to get the job done. You might consider introducing a check to see if the arguments exist, some kind of response to help or missing arguments and will likely need to test the types of characters that will appear within the variables to ensure there are no delimiters or escape characters.
- 08-01-2008 #3Just Joined!
- Join Date
- Jul 2008
- Posts
- 2
@bigtomrodney, thanks for the quick reply, i will defenetly try it out and see if it works. Do you think if we just use version and remove the release part, that it will accept argument that has either 1.52-1pclos2007 or 1.6.2 as the same argument type?
what i'm trying to say is, instead of having 3 arguments, it will have 2, and the 2nd can then accept either of the options i wrote. Again, thank you for the quick reply, much appriciated!
- 08-01-2008 #4Linux Guru
- Join Date
- Nov 2004
- Posts
- 6,110
Well the variables aren't defined or declared based on a datatype or a specific string. In this case they are placeholder and quite simple. If you replace $version-$release with just $version you can just define $version as $2, the second parameter.
Last edited by bigtomrodney; 08-01-2008 at 10:53 AM.


Reply With Quote