Login
User Name:

Password:



Register
Forgot your password?
Vote for Us!
Couple bugs
Dec 12, 2017, 5:42 pm
By Remcon
Bug in disarm( )
Nov 12, 2017, 6:54 pm
By GatewaySysop
Bug in will_fall( )
Oct 23, 2017, 1:35 am
By GatewaySysop
Bug in do_zap( ), do_brandish( )
Oct 18, 2017, 1:52 pm
By GatewaySysop
Bug in get_exp_worth( )
Oct 10, 2017, 1:26 am
By GatewaySysop
LOP 1.45
Author: Remcon
Submitted by: Remcon
LOP Heroes Edition
Author: Vladaar
Submitted by: Vladaar
Heroes sound extras
Author: Vladaar
Submitted by: Vladaar
6Dragons 4.3
Author: Vladaar
Submitted by: Vladaar
Memwatch
Author: Johan Lindh
Submitted by: Vladaar
Users Online
CommonCrawl, Yandex

Members: 0
Guests: 9
Stats
Files
Topics
Posts
Members
Newest Member
477
3,705
19,232
608
LAntorcha
Today's Birthdays
There are no member birthdays today.
Related Links
» SmaugMuds.org » Codebases » SmaugFUSS » Startup script makes some ass...
Forum Rules | Mark all | Recent Posts

Startup script makes some assumptions....
< Newer Topic :: Older Topic > ack! I don't use cshell, I use bash

Pages:<< prev 1 next >>
Post is unread #1 May 12, 2010, 7:46 am
Go to the top of the page
Go to the bottom of the page

boris
Fledgling
GroupMembers
Posts5
JoinedMay 11, 2010

Hello friendly group.

More questions from a newbie:

Here are the errors I'm seeing in nohup.out when I try to run startup:

./startup: line 11: limit: command not found
./startup: line 12: limit: command not found
./startup: line 13: syntax error near unexpected token `rm'
./startup: line 13: `if ( -e shutdown.txt ) rm -f shutdown.txt'


Here is my startup script (I edited changed line 1 and commented out # if ( "$1" != "" ) set port="$1" ).

#! /bin/bash -f

# Set the port number.
set port = 4020
# if ( "$1" != "" ) set port="$1"

# Change to area directory.
cd ../area

# Set limits.
limit coredumpsize unlimited
limit stacksize unlimited
if ( -e shutdown.txt ) rm -f shutdown.txt

while ( 1 )
    # If you want to have logs in a different directory,
    #   change the 'set logfile' line to reflect the directory name.
    set index = 1000
    while ( 1 )
        set logfile = ../log/$index.log
        if ( ! -e $logfile ) break
        @ index++
    end

    # Record starting time
    date > $logfile
    date > ../area/boot.txt

    # Run SMAUG.
    # Check if already running
    set matches = `netstat -an | grep ":$port " | grep -c LISTEN`
    if ( $matches >= 1 ) then
        # Already running
        echo Port $port is already in use.
        exit 0
    endif
    ../src/smaug $port >&! $logfile

    # Restart, giving old connections a chance to die.
    if ( -e shutdown.txt ) then
        rm -f shutdown.txt
        exit 0
    endif
    sleep 5
end


I'm running ubuntu Linux 2.6.32 i686 GNU/Linux. I saw a forum post to ignore limits (here: http://www.gammon.com.au/forum/bbshowpost.php?bbsubject_id=6533), however, I'm still unable to connect to the mud. I'll keep pecking away at this, but I would appreciate any suggestions.

Warmly,

Boris




       
Post is unread #2 May 12, 2010, 8:04 am
Go to the top of the page
Go to the bottom of the page

Zeno
Sorcerer
GroupMembers
Posts723
JoinedMar 5, 2005

If you change the script from csh to bash, you need to redo the script for bash. For example, I believe if uses [ ] instead of ( )
       
Post is unread #3 May 12, 2010, 8:08 am
Go to the top of the page
Go to the bottom of the page

boris
Fledgling
GroupMembers
Posts5
JoinedMay 11, 2010

Thank you :-)

I'm re-writing it now - I will test it and post it so others might have some luck if they are using bash.

thank you!!

Boris
       
Post is unread #4 May 12, 2010, 10:09 am
Go to the top of the page
Go to the bottom of the page

David Haley
Sorcerer
GroupMembers
Posts903
JoinedJan 29, 2007

The shell that you use is rather irrelevant to the shell used to interpret a startup script: it can be interpreted in any number of languages, including languages like Ruby, Python, Lua, etc.

You really shouldn't need to rewrite the startup script, unless you're doing it as some kind of academic exercise.
       
Post is unread #5 May 12, 2010, 11:08 am   Last edited May 12, 2010, 11:10 am by boris
Go to the top of the page
Go to the bottom of the page

boris
Fledgling
GroupMembers
Posts5
JoinedMay 11, 2010

Hello there!

Sadly, the startup script (as included) simply does not work on bash for a lot of reasons :-)

do/while is different
if /fi is different
no limit command
EOF stuff is different
file redirection doesn't work the same way
setting path's is different

yadda yadda yadda.......

So it's certainly not for academic I just want to start my mud :-) I should of been clearer in my post, though. I am not re-writing the startup script, I am fixing the startup script so it is functional in a BASH environment.

Thank you for your encouragement!

Warmly,

Boris





       
Post is unread #6 May 12, 2010, 11:43 am
Go to the top of the page
Go to the bottom of the page

David Haley
Sorcerer
GroupMembers
Posts903
JoinedJan 29, 2007

I run zsh and the startup scripts are all in (t)csh ...

The fact that you are in a bash environment is (in this case) irrelevant to the language the startup script is in.

Scripts are interpreted by an interpreter, which is a distinct process from the shell interpreter that you are using.

So you can have your bash shell, and run tcsh scripts -- that's perfectly fine, and in fact happens all the time.

Why did you change the script from tcsh to bash in the first place?
       
Post is unread #7 May 12, 2010, 11:54 am
Go to the top of the page
Go to the bottom of the page

Kayle
Off the Edge of the Map
GroupAdministrators
Posts1,195
JoinedMar 21, 2006

I work in a bash shell too. And the startup script you're saying doesn't work, works just fine for me.
       
Post is unread #8 May 12, 2010, 12:02 pm
Go to the top of the page
Go to the bottom of the page

David Haley
Sorcerer
GroupMembers
Posts903
JoinedJan 29, 2007

Boris said:

I edited changed line 1

That's your problem: by doing that, you broke the script, which is supposed to be in tcsh. Chances are that you simply didn't have tcsh installed, and so it wasn't working.

Leave the script as it was, and make sure that tcsh is installed. In this case, you broke things by "fixing" them. :wink:
       
Post is unread #9 May 12, 2010, 12:30 pm
Go to the top of the page
Go to the bottom of the page

ayuri
Magician
GroupMembers
Posts239
JoinedJun 13, 2008

Ubuntu doesn't have (t)csh installed by default. You need to apt-get it or ask your hosting provider to install. Thats why he's rewriting it to work in bash. Perhaps we should look into making the startup scripts work in bash by default? There seems to be more than a few posts about this very thing here. Or at least add a comment to the startup file saying "This script is ment for (t)csh, please make sure you have it installed".

ayuri
       
Post is unread #10 May 12, 2010, 1:44 pm
Go to the top of the page
Go to the bottom of the page

David Haley
Sorcerer
GroupMembers
Posts903
JoinedJan 29, 2007

Yes, the problem is that it's not installed. But generally, any MUD host will have tcsh, and if you run your own it's very easy to install.

That said if somebody wants to write a startup script that works in bash, that'd be great.

In the meantime, yes, adding a comment about installing tcsh would be a good idea. At least it'd prevent people from outsmarting themselves by changing it to bash or something like that. :tongue:
       
Post is unread #11 May 12, 2010, 3:41 pm
Go to the top of the page
Go to the bottom of the page

Samson
Black Hand
GroupAdministrators
Posts3,639
JoinedJan 1, 2002

The startup.sh file from AFKMud:

#! /bin/bash
# Set the port number.

if [ -n $1 ]
 then port=$1
    echo "I am now listening on port $port as you specified."
else
 port=9500
    echo "You did not specify a port to run on. I have set it to $port. To specify a port number, port 9500 for example, please use nohup ./startup 9500"
fi

echo listening on port $port

# Change to area directory.
cd ../area

# Initial shutdown.txt file check and removal.
if [ -e shutdown.txt ]  # Start Clean.
 then
  rm -f shutdown.txt
  echo "Initial shutdown file removal machine"
 else
  echo "No shutdown file found. Continuing..."
fi

# Check if port specified is available.
echo checking port $port
mandible=$(netstat -an | grep :$port | grep -c LISTEN)

    if [ $mandible -gt 0 ]
      then
    echo Port $port is already in use.
        exit 0
      else
    echo "Port check success! $port is not already in use"
    fi

while [ 1 ]
do
    # Run AFKMud.
    ../src/afkmud "$port"

    # Restart, giving old connections a chance to die.
    if [ -e shutdown.txt ]
     then
    exit 0
    fi
sleep 5
done


Can't guarantee it works as I've never used it. Adapt as you see fit.
       
Pages:<< prev 1 next >>