Web Hosting Talk







View Full Version : Need some bash scripting help


ThatScriptGuy
04-08-2007, 03:22 PM
Basically, I've got a demo of a script available and every hour or so, I'd like to have it reset. So basically I need the bash script to execute the following commands:

1. rm -rf /home/demo.domain.com/public_html/*
2. Unpack files.tgz to /home/demo.domain.com/public_html/*
3. mysql -u [dbuser] -p[dbpass] -h localhost [dbname] < database.sql

I really just don't know anything about bash scripting, and I'm assuming that that is the best way to go about it...
Kevin

rghf
04-08-2007, 03:32 PM
You just write a bash scripts as a list of commands. Something like

#!/bin/bash
rm -rf /home/demo.domain.com/public_html/*
tar -zxf files.tgz -C /home/demo.domain.com/public_html/
mysql -u [dbuser] -p[dbpass] -h localhost [dbname] < database.sql

then chmod a+x the file and you should be all set (do test that before though as I'm not sure about the tar line)

ThatScriptGuy
04-08-2007, 03:34 PM
Heh..Never realized it was that easy.

Ks Jeppe
04-08-2007, 04:48 PM
Heh..Never realized it was that easy.
Niether did i :o thanks a2b2 :D