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

    Syntax Error - .sh


    I'm getting a syntax error whenever I bash my launch.sh. Here's the error and the sh paste.


    [root server1]# bash launch.sh
    : No such file or directoryDIR #this one confuses me too
    'aunch.sh: line 10: syntax error near unexpected token `do
    'aunch.sh: line 10: ` do



    ===============================

    #!/bin/sh
    BINDIR=$(dirname "$(readlink -fn "$0")")
    cd "\$BINDIR"
    while true
    do
    screen -S 0 java -Xmx1024M -Xms1024M -jar spigot.jar
    echo "If you want to completely stop the server process now, press Ctrl+C before the time is up!"
    echo "Rebooting in:"
    for i in 5 4 3 2 1
    do
    echo "$i..."
    sleep 1
    done
    echo "Rebooting now!"
    done

  2. #2
    i'm guessing you wrote the code in Windows, then copied it over to linux? there are probably carriage returns in there. see them with this:

    Code:
    cat -v launch.sh
    you'd see them as ^M characters.

    you can remove them with:

    Code:
    dos2unix launch.sh
    you may have to install that util first.

    you can also use sed or perl one-liners to remove them.

    Best bet is to use a Windows prog like notepad++ that allows you to write files "for Linux" (w/o embedding Window carriage returns in them).

  3. #3
    Wow. I'm a moron. Perfect answer. Thank you so much for the help!

  4. $spacer_open
    $spacer_close
  5. #4
    Quote Originally Posted by Poggy View Post
    Wow. I'm a moron. Perfect answer. Thank you so much for the help!
    definitely NOT a moron! that must happen at least once to every single Windows user who is coding for a Linux box.

Posting Permissions

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