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.



Related articles

3 comments

Read the comments left by other users below, or:

Get your own gravatar by visiting gravatar.com poker casino972
#1. March 28th, 2006, at 8:43 PM.

poker casino poker 681

Get your own gravatar by visiting gravatar.com 搜索引擎优化
#2. May 8th, 2007, at 4:18 AM.

Web page

Trackback Mention from Xdiscover.com
#3. August 17th, 2007, at 5:30 AM.

Freeware and Shareware Software Downloads: Freeware and Shareware Software Downloads... I couldn't understand some parts of this article, but it sounds interesting...

Leave your comment...

If you want to leave your comment on this article, simply fill out the next form:




You can use these XHTML tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong> .