Requirements Testing

February 24th, 2006

You are currently browsing the articles from TechToolBlog written on February 24th, 2006.

SMB Files from Unix to Windows 2003 Share Folder

We have our Web server running on a MAC OS X machine while our Web reporting software, NetTracker, runs on a Windows 2003 server. We needed to get the data across everyday so our reporting could be real time minus one day. I ended up writing a shell script to move the data: Hopefully this will help out someone out there.

*NOTE: This assumes you are doing a daily dump of your Apache log files

#! /bin/bash
#####################################################
# http://www.techtoolblog.com
#####################################################

DATETIME=`date +%m-%d-%Y`

cd /var/log/httpd
# On Sunday - Apache does a dump of the weeks worth of data
# we need to archive it
mv access_log.0.gz week_$DATETIME.gz

# Else rename the daily log file first -
mv access_log.*.gz log_$DATETIME.gz

# Now lets gunzip it
gunzip log_$DATETIME.gz

# Time to chmod for so right permissions come over to Windows
chmod 777 log_$DATETIME

#Now put it on your Windows Share
smbclient //YourServerName/Logs -UMyUserName%MyDomainName -W DomainName -c "prompt; mput log_$DATETIME; exit;"

exit 0

I still need to write some type of logging into the script incase there is an error. Also, there is a way to specify a encrypted file name for the password instead of having the password in your script, but I ended up changing the permission on the actual script file so only root could read it, root is the user running the cron job, so that should be enough security.

Written by Tim on February 24th, 2006 with 3 comments.
Read more articles on unix.