Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   Bash / Shell Scripting (http://www.programmingforums.org/forum26.html)
-   -   Bad interpreter? (http://www.programmingforums.org/showthread.php?t=8808)

a thing Mar 10th, 2006 11:41 PM

Bad interpreter?
 
:

#!/bin/sh
# Installer for Nexuiz 1.5 on GNU/Linux.
#confirm download
{
        printf "Welcome to the Nexuiz 1.5 for GNU/Linux installer!\nWARNING! Nexuiz's download is 178MB, so should take at least a few minutes. Really continue? "
        read dl
        dl="`echo $dl|tr 'A-Z' 'a-z'`"
        if [ "$dl" != "y" ] && [ "$dl" != "yes" ]; then
                exit
        fi
}

#make sure $installdir is global
installdir=''

#download and extract
{
        get_installdir ()
        {
                printf "Where do you want to install Nexuiz? If you do not enter anything, Nexuiz will be installed to /usr/local/games/. "
                read installdir
                if [ -z "$installdir" ]; then
                        installdir="/usr/local/games/"
                fi
                if [ ! -d "$installdir" ]; then
                        printf "Error! $installdir is not a directory!\n"
                        get_installdir
                fi
                if [ ! -w "$installdir" ]; then
                        printf "Error! You do not have write permission in $installdir!\n"
                        get_installdir
                fi
                #remove trailing /
                {
                        if  [ "echo ${installdir:`expr ${#installdir} - 1`}" == "/" ]; then
                                installdir="${installdir:0:`expr ${#installdir} - 1`}"
                        fi
                }
        }
        get_installdir
        cd $installdir
        #wget http://easynews.dl.sourceforge.net/s.../nexuiz-15.zip
        printf "Extracting archive...\n"
        unzip nexuiz-15.zip
}

#remove unneeded stuff
{
        #archive
        {
                printf "Keep 178MB downloaded archive? "
                read archive
                archive="`echo $archive|tr 'A-Z' 'a-z'`"
                if [ "$archive" != "y" ] || [ "$archive" != "yes" ]; then
                        rm nexuiz-15.zip
                fi
        }
        #check CPU architecture
                if [ "`uname -m`" == "i686" ]; then
                        arch="686"
                        notarch="x86_64"
                elif [ "`uname -m`" == "x86_64" ]; then
                        arch="x86_64"
                        notarch="686"
                else
                        echo "Error! Your CPU architecture is not supported by the prebuilt Nexuiz binaries. You might be able to compile Nexuiz yourself. Instructions on the WWW at http://www.alientrap.org/forum/viewtopic.php?p=353#353\n"
                        exit 1
                fi
        #ask for source
        {
                printf "Keep source? "
                read source
                source="`echo $source|tr 'A-Z' 'a-z'`"
                if [ "$source" != "y" ] || [ "$source" != "yes" ]; then
                        source='*source*'
                fi
        }
        #remove files
        {
                cd Nexuiz
                rm -rf *exe* *dll* *.app* "$source" "nexuiz-linux-$notarch-sdl" "nexuiz-linux-$notarch-dedicated" nexuiz-linux.sh
        }
        #remove unneeded things in binary names
        {
                mv -f nexuiz-linux-$arch-sdl nexuiz-sdl
                mv -f nexuiz-linux-$arch-dedicated nexuiz-dedicated
        }
}

#create starter scripts
{
        cd ..
        printf "#\!/bin/sh\ncd $installdir/Nexuiz\n./nexuiz-sdl \$@\n">nexuiz-sdl
        printf "#\!/bin/sh\ncd $installdir/Nexuiz\n./nexuiz-dedicated \$@\n">nexuiz-dedicated
        ln -fs nexuiz-sdl nexuiz
}

#display GGPL
{
        printf "Nexuiz license (the GGPL) will display in 3 seconds. Hit \"q\" to exit it.\n"
        sleep 3
        #for the few systems without less
        {
                whereis less>/dev/null
                if [ "$?" == "0" ]; then
                        viewer="less"
                else
                        viewer="more"
                fi
        }
        $viewer Nexuiz/gpl.txt
}

#leaving message
{
        case $PATH in
                *$installdir*)
                        printf "Nexuiz installed! Just enter \"nexuiz\" to play Nexuiz. You can also use \"nexuiz-dedicated\" to start a dedicated server or \"nexuiz-sdl\".\n";;
                *)
                        printf "Nexuiz installed! However $installdir is not in your \$PATH.\n";;
        esac
}


When I try to run it:
:

notroot[0:scripts]& NexuizInstaller
: bad interpreter: No such file or directoryin/sh
notroot[0:scripts]&


It doesn't make a difference if I use /bin/sh or /bin/bash.

Other shell scripts work fine. I've no clue what's wrong.

Arevos Mar 11th, 2006 3:43 AM

Try using the dos2unix command on the shell script. I know I've had problems in the past with shell scripts formatted with \r\ns instead of \ns.

a thing Mar 11th, 2006 11:40 AM

That fixed it :) Ionno why it would have DOS EOFs.

jim mcnamara Mar 14th, 2006 9:32 AM

vi or nano both show ^M at the end of a line when you have this problem.

DaveQB May 18th, 2006 3:31 AM

Or just have [dos] etc displayed down the botton whilst the file is open.
this in vi will fix it too

:se ff=unix


All times are GMT -5. The time now is 11:07 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC