Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: Apparently I have a invisible typo

  1. #1
    Join Date
    Jun 2009
    Location
    0:0:0:0:0:0:0:1
    Beans
    4,601
    Distro
    Xubuntu 13.04 Raring Ringtail

    Apparently I have a invisible typo

    I have been over the code a dozen or so times and i don't see why i am getting a error
    Code:
     cat -n script 
         1    #!/bin/sh
         2    # This script is for installing from a recovery console where you can't copy/paste
         3    if [ "$USER" = "root" ];then
         4        echo "Do not run me as root\nYou can run me using this:\n\tsudo -u userNameOtherThanRoot $(basename $0)"
         5        exit
         6    fi
         7    cd /tmp
         8    zip="Ubuntu-Mainline-Kernel-Updater.zip"
         9    url="//github.com/GM-Script-Writer-62850/Ubuntu-Mainline-Kernel-Updater"
        10    if [ -f "/usr/bin/git" ];then
        11        git clone "git:$url"
        12    elif [ -f "/usr/bin/wget" ];then
        13        wget "https://$url/archive/master.zip" -O "$zip"
        14    elif [ -f "/usr/bin/curl" ];then
        15        curl "https://$url/archive/master.zip" > "$zip"
        16    else
        17        echo "You need to install git, curl, or wget to run this script"
        18        exit
        19    fi
        20    if [ -f "/tmp/$zip" ];then
        21        unzip "$zip"
        22        bash Ubuntu-Mainline-Kernel-Updater-master/install
        23    else
        24        bash Ubuntu-Mainline-Kernel-Updater/install
        25    fi
        26    KernelUpdateChecker -no-rc
    chad@A54C-NB91:/tmp$ sh script 
    script: 12: script: Syntax error: "elif" unexpected (expecting "then")
    Last edited by pqwoerituytrueiwoq; April 30th, 2013 at 03:19 AM. Reason: Solved
    Laptop: ASUS A54C-NB91 (Storage: WD3200BEKT + MKNSSDCR60GB-DX); Desktop: Custom Build - Images included; rPi Server
    Putting your Networked Printer's scanner software to shame PHP Scanner Server
    I frequently edit my post when I have the last post

  2. #2
    Join Date
    Jul 2007
    Location
    Poland
    Beans
    4,499
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: Apparently I have a invisible typo

    are you sure you don't have some \r there attached to then which makes shell not recognize that then as a keyword?

    Code:
    $ eval $'if [ 1 ];then echo a; elif true; then echo b; else echo c; fi'
    a
    $ eval $'if [ 1 ];then\r echo a; elif true; then echo b; else echo c; fi'
    bash: syntax error near unexpected token `elif'
    Last edited by Vaphell; April 29th, 2013 at 09:09 PM.
    if your question is answered, mark the thread as [SOLVED]. Thx.
    To post code or command output, use [code] tags.
    Check your bash script here // BashFAQ // BashPitfalls

  3. #3
    Join Date
    Feb 2013
    Beans
    Hidden!

    Re: Apparently I have a invisible typo

    +1
    cat -v will display non-printing characters as ^C. Also, try to execute the script with bash script as bash' error messages usually better comprehensible.
    Last edited by schragge; April 29th, 2013 at 09:37 PM.

  4. #4
    Join Date
    Jun 2009
    Location
    0:0:0:0:0:0:0:1
    Beans
    4,601
    Distro
    Xubuntu 13.04 Raring Ringtail

    Re: Apparently I have a invisible typo

    see anything now? i don't
    Code:
    $ cat script -nv
         1    #!/bin/sh^M
         2    # This script is for installing from a recovery console where you can't copy/paste^M
         3    if [ "$USER" = "root" ];then^M
         4        echo "Do not run me as root\nYou can run me using this:\n\tsudo -u userNameOtherThanRoot $(basename $0)"^M
         5        exit^M
         6    fi^M
         7    cd /tmp^M
         8    zip="Ubuntu-Mainline-Kernel-Updater.zip"^M
         9    url="//github.com/GM-Script-Writer-62850/Ubuntu-Mainline-Kernel-Updater"^M
        10    if [ -f "/usr/bin/git" ];then^M
        11        git clone "git:$url"^M
        12    elif [ -f "/usr/bin/wget" ];then^M
        13        wget "https://$url/archive/master.zip" -O "$zip"^M
        14    elif [ -f "/usr/bin/curl" ];then^M
        15        curl "https://$url/archive/master.zip" > "$zip"^M
        16    else^M
        17        echo "You need to install git, curl, or wget to run this script"^M
        18        exit^M
        19    fi^M
        20    if [ -f "/tmp/$zip" ];then^M
        21        unzip "$zip"^M
        22        bash Ubuntu-Mainline-Kernel-Updater-master/install^M
        23    else^M
        24        bash Ubuntu-Mainline-Kernel-Updater/install^M
        25    fi^M
        26    KernelUpdateChecker -no-rc^M
    Laptop: ASUS A54C-NB91 (Storage: WD3200BEKT + MKNSSDCR60GB-DX); Desktop: Custom Build - Images included; rPi Server
    Putting your Networked Printer's scanner software to shame PHP Scanner Server
    I frequently edit my post when I have the last post

  5. #5
    Join Date
    Apr 2012
    Beans
    6,625

    Re: Apparently I have a invisible typo

    yeah all those ^M characters are Windows-style carriage returns - you need to strip them all off e.g.

    Code:
    tr -d $'\r' < script > newscript

  6. #6
    Join Date
    Jul 2007
    Location
    Poland
    Beans
    4,499
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: Apparently I have a invisible typo

    proof:
    Code:
    $ cat -v <( echo $'abc\r' )
    abc^M
    if your question is answered, mark the thread as [SOLVED]. Thx.
    To post code or command output, use [code] tags.
    Check your bash script here // BashFAQ // BashPitfalls

  7. #7
    Join Date
    Jun 2009
    Location
    0:0:0:0:0:0:0:1
    Beans
    4,601
    Distro
    Xubuntu 13.04 Raring Ringtail

    Re: Apparently I have a invisible typo

    Guess I cant host a script on pastebin.com and download the raw script and it work... guess they use a windows server...
    Laptop: ASUS A54C-NB91 (Storage: WD3200BEKT + MKNSSDCR60GB-DX); Desktop: Custom Build - Images included; rPi Server
    Putting your Networked Printer's scanner software to shame PHP Scanner Server
    I frequently edit my post when I have the last post

  8. #8
    Join Date
    Oct 2011
    Location
    ZZ9 Plural Z Alpha
    Beans
    Hidden!
    Distro
    Ubuntu

    Re: Apparently I have a invisible typo

    You probably already have tried this, but it can be useful to run the script with the debugging flag:

    Code:
    bash -x myscript.sh

  9. #9
    Join Date
    Mar 2005
    Location
    Isle of Bute, Scotland
    Beans
    369
    Distro
    Ubuntu Gnome 14.04 Trusty Tahr

    Re: Apparently I have a invisible typo

    What if you zipped it up before uploading and get the user to unzip it after they download it?
    Running 14.04 on my HP Pavilion g6 4 Gig Ram 320 Gig Disc

  10. #10
    Join Date
    Jun 2009
    Location
    0:0:0:0:0:0:0:1
    Beans
    4,601
    Distro
    Xubuntu 13.04 Raring Ringtail

    Re: Apparently I have a invisible typo

    i just used the tr command to patch the download in the readme file
    Laptop: ASUS A54C-NB91 (Storage: WD3200BEKT + MKNSSDCR60GB-DX); Desktop: Custom Build - Images included; rPi Server
    Putting your Networked Printer's scanner software to shame PHP Scanner Server
    I frequently edit my post when I have the last post

Page 1 of 2 12 LastLast

Bookmarks

Posting Permissions

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