Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Mar 10th, 2006, 11:41 PM   #1
a thing
Unverified User
 
a thing's Avatar
 
Join Date: Aug 2005
Location: none
Posts: 146
Rep Power: 0 a thing is on a distinguished road
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.
__________________
Warning: My posts may change (dramatically) within the first 15 minutes they're posted.
Got 'Nux?—GNU/Linux and other free software support.
It's GNU/Linux, not just Linux.
a thing is offline   Reply With Quote
Old Mar 11th, 2006, 3:43 AM   #2
Arevos
Programming Guru
 
Arevos's Avatar
 
Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 4 Arevos is on a distinguished road
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.
Arevos is offline   Reply With Quote
Old Mar 11th, 2006, 11:40 AM   #3
a thing
Unverified User
 
a thing's Avatar
 
Join Date: Aug 2005
Location: none
Posts: 146
Rep Power: 0 a thing is on a distinguished road
That fixed it Ionno why it would have DOS EOFs.
__________________
Warning: My posts may change (dramatically) within the first 15 minutes they're posted.
Got 'Nux?—GNU/Linux and other free software support.
It's GNU/Linux, not just Linux.
a thing is offline   Reply With Quote
Old Mar 14th, 2006, 9:32 AM   #4
jim mcnamara
Hobbyist Programmer
 
Join Date: Jun 2005
Location: New Mexico
Posts: 228
Rep Power: 4 jim mcnamara is on a distinguished road
vi or nano both show ^M at the end of a line when you have this problem.
jim mcnamara is offline   Reply With Quote
Old May 18th, 2006, 3:31 AM   #5
DaveQB
Newbie
 
DaveQB's Avatar
 
Join Date: Apr 2006
Location: Sydney
Posts: 14
Rep Power: 0 DaveQB is on a distinguished road
Send a message via ICQ to DaveQB Send a message via Skype™ to DaveQB
Or just have [dos] etc displayed down the botton whilst the file is open.
this in vi will fix it too

:se ff=unix
DaveQB is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 6:13 PM.

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