Results 1 to 5 of 5

Thread: Shell script that will install rar on linux

  1. #1
    Senior Member vamsi's Avatar
    Join Date
    Nov 2009
    Location
    Bangalore / India
    Posts
    263
    Thanks
    138
    Thanked 14 Times in 12 Posts
    Rep Power
    5

    Thumbs up Shell script that will install rar on linux

    Hi...
    I am learning shell scripting for fun and doing some automation
    its very simple but useful for me..
    please tell me , how I can improve this code ?
    I thought of finding Distro and then installing the one specified for that Distro, but the commands used will work on every distro
    PHP Code:
    #!/bin/bash
    # simple bash script that will install rar
    # vamsi
    # http://www.cyberciti.biz/faq/open-rar-file-or-extract-rar-files-under-linux-or-unix/
    echo "This script will install rar on your box"
    echo "The installation will begin in 5 seconds"
    echo "Press Ctrl+C to cancel"
    sleep 5
    # go to a temp directory
    cd /tmp
    # detecting the architecture
    if $(uname -grep 'x86_64'); then
      
    echo "this is 64 bit os, so lets install 64bit winrar"
      
    wget http://rarlab.com/rar/rarlinux-x64-3.8.0.tar.gz
      
    tar -zxvf rarlinux-x64-3.8.0.tar.gz
      cd rar
      
    ./unrar
    else
      echo 
    "this is 32 bit os, so lets install 32bit winrar"
      
    wget http://www.rarlab.com/rar/rarlinux-3.8.0.tar.gz
      
    tar -zxvf rarlinux-3.8.0.tar.gz
      cd rar
      
    ./unrar
    fi
    cp rar unrar 
    /bin
    echo "rar sucessfully installed" 
    Regards
    Last edited by vamsi; 10th December 2010 at 07:53 AM.
    shebangs

  2. #2
    Senior Member
    Join Date
    Sep 2006
    Posts
    131
    Thanks
    0
    Thanked 33 Times in 29 Posts
    Rep Power
    10

    Default

    you might want to improve on that considering next time, the version might change. Perhaps use wget to get the main page, parse it for the latest version, and then download it.

  3. #3
    Senior Member
    Join Date
    Jun 2005
    Posts
    194
    Thanks
    39
    Thanked 13 Times in 10 Posts
    Rep Power
    9

    Default

    Quote Originally Posted by ghostdog74 View Post
    you might want to improve on that considering next time, the version might change. Perhaps use wget to get the main page, parse it for the latest version, and then download it.
    May be add $version and just get it on fly:
    Code:
    arch="x64"
    version="3.8.0"
    url="http://rarlab.com/rar/rarlinux-$arch-$version.tar.gz"
    
    # down somewhere 
    wget "$url"
    Last edited by jerry; 18th January 2010 at 03:32 PM. Reason: typo
    Learning shell and Perl scripting was one of best things I did..

  4. #4
    Senior Member
    Join Date
    Sep 2006
    Posts
    131
    Thanks
    0
    Thanked 33 Times in 29 Posts
    Rep Power
    10

    Default

    no, that's not what i meant. if the latest version becomes 3.9, i don't want to edit the script to change the values. I want the script to detect the latest version automatically.

  5. #5
    Never say die nixcraft's Avatar
    Join Date
    Jan 2005
    Location
    BIOS
    Posts
    4,371
    Thanks
    17
    Thanked 754 Times in 496 Posts
    Rep Power
    10

    Default

    I think, the main problem with auto-detection is lack of standard format. There should some sort of XML format that include version and ftp location. Sure you can write kungfu using curl / sed / lynx and friends. but what if destination web page author changed his / her page layout or moved to another domain? The script will fail. There are a few solutions (and there may be more...):

    1. Use a config. Only edit the same. Include this file in your script.
    2. Use a Makefile file. Only edit the same. This is what FreeBSD ports does and it works quite nicely.
    3. Write your kungfu script with some sort of fallback solution.
    Last edited by nixcraft; 18th January 2010 at 04:42 PM. Reason: Typos
    All [Solved] threads are closed by mods / admin to avoid spam issues. See Howto mark a thread as [Solved]


  6. The Following User Says Thank You to nixcraft For This Useful Post:

    vamsi (10th December 2010)

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Shell script to install from build machine
    By Divine in forum Shell scripting
    Replies: 3
    Last Post: 15th January 2010, 12:41 PM
  2. Linux Add User Shell Script
    By abovenewbi in forum Shell scripting
    Replies: 13
    Last Post: 6th March 2009, 02:57 AM
  3. GUI shell script for Linux
    By mr_aliagha in forum Shell scripting
    Replies: 2
    Last Post: 6th December 2008, 02:30 AM
  4. Linux shell script progarmming
    By zakkiya.sultana in forum Shell scripting
    Replies: 1
    Last Post: 20th October 2008, 09:39 AM
  5. Linux UNIX SFTP in a Shell Script
    By Nishanthhampali in forum Shell scripting
    Replies: 1
    Last Post: 30th January 2008, 01:16 PM

Tags for this Thread

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41