Find the answer to your Linux question:
Results 1 to 4 of 4
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    Thumbs up 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

  2. #2
    Linux Guru bigtomrodney's Avatar
    Join Date
    Nov 2004
    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 yourself
    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
    In the example above, $1 represents the first argument etc.

    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.

  3. #3
    @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!

  4. $spacer_open
  5. #4
    Linux Guru bigtomrodney's Avatar
    Join Date
    Nov 2004
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts