string var=string var in bash script

Problems
2012-01-14
2013-05-28
  • David Siembab
    David Siembab
    2012-01-14

    in the elif's you have a string being cast to another string so just change $DISTRO to DISTRO. plus no desktop icon, but I am sure that will get done :) it all takes time nice application for lxde keep up the good work

     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
    #!/bin/bash
    # discovered distro; Debian by default
    DISTRO='Debian'
    # distro names
    DEBIAN='Debian'
    SUSE='SuSe'
    REDHAT='RedHat'
    MANDRAKE='Mandrake'
    #######################################################################
    # DISTRIBUTION DETECTION
    ########################################################################
    if [ -f /etc/redhat-release ] ; then
        DISTRO=$REDHAT
    elif [ -f /etc/fedora-release ] ; then
        DISTRO=$REDHAT
    elif [ -f /etc/SuSE-release ] ; then
        DISTRO=$SUSE
    elif [ -f /etc/mandrake-release ] ; then
        DISTRO=$MANDRAKE
    elif [ -f /etc/debian_version ] ; then
        DISTRO=$DEBIAN
    fi
    ########################################################################
    # start the application
    if [ "${DISTRO}" = "${SUSE}" ];
    then
        gnomesu --command "java -jar /opt/lxmed/LXMenuEditor.jar"
    else
        gksu --message "Please enter password to run lxmed in fully operational mo$
    fi
    
     
  • David Siembab
    David Siembab
    2012-01-14

    also on first run instead of gksu you could just us

    su -c 'java -jar /opt/lxmed/LXMenuEditor.jar'
    

    on fedora it will prompt for a password

     
  • Marko Čičak
    Marko Čičak
    2012-01-14

    does it mean that instead of
    DISTRO=$REDHAT
    I need to write
    $DISTRO=$REDHAT?

     
  • David Siembab
    David Siembab
    2012-01-14

    no i changed the file i posted. If you compare the two you will see that the one being people are downloading is different. you have DISTRO='Debian' as the default, so the $DISTRO variable = 'Debian';
    the  is the original i downloaded this morning
    had

    if [ -f /etc/redhat-release ] ; then 
        $DISTRO=$REDHAT 
    elif [ -f /etc/SuSE-release ] ; then 
        $DISTRO=$SUSE
     elif [ -f /etc/mandrake-release ] ; then 
        $DISTRO=$MANDRAKE 
    elif [ -f /etc/debian_version ] ; then 
        $DISTRO=$DEBIAN 
    fi
    

    so you were casting a string variable to a string variable; I just took out the "$" in front of the variables so you were setting DISTRO to the OS variables like you intended to do

     
  • Marko Čičak
    Marko Čičak
    2012-01-15

    Oh I see now :)

    Thanks for pointing that out! I will make a correction in the next version.

    Greetings.