Linux Scripting

I been upgraded to a PS and since it’s linux I’m trying to figure out how to run a file on my server. I have a file called ventrilo_srv which I can manually run from putty by typing ./ventrilo_srv -d

Piece of cake, but I was reading something online about scripting and wanted to see what you guys know and but the dir and script is below:

ventrilo_srv ( where the file is stored

The script I found online:

case “$1” in
echo "Starting Ventrilo Server."
cd /pathtoventrilo/
/ventrilo_srv -d
echo “Ventrilo Server Started”
echo "Shutting Down Ventrilo Server."
cd /pathofventrilo/
kill cat
echo “Ventrilo Server Is Now Down”
echo "Restarting Ventrilo Server…"
cd /pathtoventrilo/
kill cat
/ventrilo_srv -d
echo “Ventrilo Server Restarted”
echo "Usage: $0 {start|stop|restart}"
exit 1
exit 0

Im using Notepad and I understand I save the file as Plz someone help if they can.

EDIT: I also did learn this ./ventrilo_srv -d but Im not understanding what the -d does?


Apparently, the -d runs it in daemon mode, so it’s more of a persistant process than a script that’s left running.

The script saves you the trouble of remembering and typing in long commands.
Start: types in the -d command to get it running.
Stop: kills the daemon by looking up the process ID recorded by the start command.
Restart: kills, then starts the daemon.

Once you save a properly formatted .sh script, you need to change permissions to it’s executable. I’d go with:
chmod 700
That way it’s read/write/executable by you and nobody else. And when I say “properly formatted,” you may have to run dos2unix:
This will fix any line returns that Notepad may have put in that’s not UNIX compatible.


Ok I got a better understanding of that now. Will the script automatically run if the server ever reboots for some reason? Where do I store the script also. Appreciate the help


I don’t have a PS account, so I don’t know if you can add the -d command to one of the rc boot scripts. But there’s often a /etc/rc.local where this stuff belongs. If you can add it to rc.local, then it’ll invoke at bootup.

The script should be in your home directory (not on your domain folder) so it can’t be accessible from a web browser.