Linux Help
guides forums blogs
Home Desktops Distributions ISO Images Logos Newbies Reviews Software Support & Resources Linuxhelp Wiki

Welcome Guest ( Log In | Register )



Advanced DNS Management
New ZoneEdit. New Managment.

FREE DNS Is Back

Sign Up Now
 
Reply to this topicStart new topic
> Sed Command Help
r.harris72
post Nov 18 2005, 11:22 AM
Post #1


Whats this Lie-nix Thing?
*

Group: Members
Posts: 1
Joined: 18-November 05
Member No.: 5,754



i have wrote a simple script for a guy that sets up game servers and works fine apart from one line of the script

here is the script dont laugh as im new to linux


#!/bin/bash

# Server INstall

clear

echo " Install One Of The Following"
echo " ------- --- -- --- ---------"
echo "Choose one of the following by inputing number then hit return"
echo
echo "1: Medal of Honour Allied Assault"
echo "2: Medal of Honour Spearhead"
echo "3: Call of Duty"
echo "4: Counterstrike"
echo "5: Teamspeak"
echo "6: Ventrillo"
echo
echo "press enter to exit"
echo

read person

case "$person" in


"1" | "1" )
echo
echo "please type a folder to install to and hit return"
echo
read folder
tar -xvvzf mohaa.tar.gz
mv server1 $folder
chmod 777 $folder/mohaa_loop.sh
cd $folder
clear

echo "please enter first set of numbers in ip before then press enter"
echo
read first
echo
sed s/195/$first/g mohaa_loop.sh > new.sh
echo
echo "please enter second set of numbers in ip before then press enter"
echo
read second
echo
sed s/20/$second/g new.sh > new1.sh
echo
echo "please enter third set of numbers in ip before then press enter"
echo
read third
echo
sed s/109/$third/g new1.sh > new2.sh
echo
echo "please enter forth set of numbers in ip before then press enter"
echo
read forth
echo
sed s/159/$forth/g new2.sh > new3.sh
echo
echo "now enter last digit of port number followed by enter"
echo
read richard
echo
sed s/12200/$richard/ new3.sh > new4.sh





echo
echo "Nearly done just size of server now and enter"
echo
read server
echo
sed s/16/$server/g new4.sh > new5.sh

rm new.sh
rm new1.sh
rm new2.sh
rm new3.sh
rm new4.sh
rm mohaa_loop.sh
mv new5.sh mohaa_loop.sh
cd /home/archive
chmod 755 $folder/mohaa_loop.sh
mv $folder /home
cd /home/$folder

clear
echo "game now installed to $folder"
echo
echo "server IP =$first.$second.$third.$forth"
echo "Port =$richard"
echo "All Thats left to do is setup ftp now"
echo "And Start the server"
echo
echo "This Script was brought to you by an old friend"

;;


"2" | "2" )
echo
echo "please type a folder to install to and hit return"
echo
read folder
tar -xvvf sh.tar
mv spearheadtest $folder


clear

echo "please enter first set of numbers in ip before then press enter"
echo
read first
echo
sed s/195/$first/g mohaa_loop.sh > new.sh
echo
echo "please enter second set of numbers in ip before then press enter"
echo
read second
echo
sed s/20/$second/g new.sh > new1.sh
echo
echo "please enter third set of numbers in ip before then press enter"
echo
read third
echo
sed s/109/$third/g new1.sh > new2.sh
echo
echo "please enter forth set of numbers in ip before then press enter"
echo
read forth
sed s/159/$forth/g new2.sh > new3.sh
echo
echo " now enter a port number followed by enter"
echo
read port
echo

sed s/12400/$port/g new3.sh > new4.sh



echo "Nearly done just size of server now and enter"
echo
read server
echo
sed s/16/$server/g new4.sh > new5.sh


rm mohaa_loop.sh
rm new.sh
rm new1.sh
rm new2.sh
rm new3.sh
rm new4.sh
mv new5.sh mohaa_loop.sh

mv $folder /home
cd /home/$folder/mohaaS/

clear

echo "game now installed to $folder"
echo "All Thats left to do is setup ftp now"
echo
echo "This Script was brought to you by an old friend"
;;


"3" | "3" )
echo
echo "please type a folder to install to and hit return"
echo
read folder
tar -xvvzf cod1.5.tar.gz
mv cod1.5 $folder
mv $folder /home
clear
echo "game now installed to $folder"
echo "All Thats left to do is setup ftp now"
echo
echo "This Script was brought to you by an old friend"
;;


"4" | "4" )
echo
echo "please type a folder to install to and hit return"
echo
read folder
tar -xvvzf counter.tar.gz
mv server7 $folder
mv $folder /home

clear

echo "game now installed to $folder"
echo "All Thats left to do is setup ftp now"
echo
echo "This Script was brought to you by an old friend"
;;


"5" | "5" )
echo
echo "please type a folder to install to and hit return"
echo
read folder
tar -xvvf team.tar
mv tss2 $folder
mv $folder /home
clear
echo "teamspeak now installed to $folder"
echo "All Thats left to do is to set it up "
echo
echo "This Script was brought to you by an old friend"
;;


"6" | "6" )
echo
echo "please type a folder to install to and hit return"
echo
read folder
tar -xvvf vent.tar
mv tlbvent $folder
mv $folder /home
clear
echo "Ventrillo now installed to $folder"
echo "All Thats left to do is to set it up "
echo
echo "This Script was brought to you by an old friend"
;;



* )
# Default option.
# Empty input (hitting RETURN) fits here, too.
echo
echo "Changed your mind then."
;;

esac

echo

exit 0


the line that refuses to work is this

echo "now enter last digit of port number followed by enter"
echo
read richard
echo
sed s/12200/$richard/ new3.sh > new4.sh

all it does when i look at the file is drop the 0 off 12200 and i want it to replace 12200 with the users input every thing else works fine cant work out why this line will not work

any ideas or how i could tidy up script would be greatfully recieved

thanks


sorry for double post bloody pc so slow today

This post has been edited by r.harris72: Nov 18 2005, 11:24 AM
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



RSS Lo-Fi Version Time is now: 12th December 2017 - 05:32 AM