views:

380

answers:

3

I have a script that constantly segfaults - the problem that I can't solve as segfault is in python libxml bindings - didn't write those. Ok, so in Linux I used to run an inf.loop so that when script dies - it restarts, like so:

#!/bin/bash
while [ 1 ]
do
nice -n 19 python server.py
sleep 1
done

Well, I can't seem to find /bin/bash in FreeBSD so that doesn't work.

Any ideas? Consider that cron is not an option - allowed downtime is a few seconds.

A: 

Not sure what shell FreeBSD uses by default, but it probably comes with a few. The man page for whatever shell you are using ought to tell you that shell's loop syntax. It's probably pretty similar.

Adam Jaskiewicz
+1  A: 

There will be some shell program on the system, and that script looks like it will run in pretty much any shell.

Type type bash to see where bash is. If not, try sh. It should be there, and it should work. Take the result of type bash or type sh, and use in in the place of /bin/bash. Alternately, look at /etc/passwd, look for your account, and notice what the shell is. I believe it's the last field, and it will say something like /bin/sh or /usr/bin/bash or whatever. Use that instead of /bin/bash.

David Thornley
+2  A: 

/bin/sh almost certainly exists, but if you really need bash:

cd /usr/ports/*/bash
make install

that should install bash in /usr/local/bin/bash i believe

Evan Teran
Although I really want to unserstand why this doesn't work under "sh", but your recipe for bash did work - installing now.
Slava N
The first line of your script says to use /bin/bash to interpret the contents of the file. Unless you change that to "sh" instead of "bash", it's going to try (and fail, since it doesn't exist) to use bash.Likewise, you'll need to point it to wherever ports ends up putting the bash executable.
Adam Jaskiewicz
Yes, I know that, what I meant is that changins shebang to "sh" just hung my system completely. It went into a real infinite loop I guess, even without sleeps.
Slava N
Check out where FreeBSD installs bash. In 4.x, I remember that installed the binary on /usr/local/bin/
Hernán