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.

Tim

A .NET, PHP, Marketing Guru authority, at least I hope I am. Reach me at tboland@gmail.com

17 thoughts on “SMB Files from Unix to Windows 2003 Share Folder

  1. Freeware and Shareware Software Downloads…

    I couldn’t understand some parts of this article, but it sounds interesting…

  2. Création site internet bretagne…

    Merci pour cet article intéressant. Bien à vous…….

  3. obat aborsi says:

    This blog is so nice to me. I will continue to come here again and again. Visit my link as well.
    Good luck

  4. thank for write article, iam student from indonesia. i have job searching baclink from great website. and this website very good and education.

  5. Thank you for sharing your thoughts. Jual obat pembesar penis terbaik.

  6. Thank you for sharing your thoughts. Jual vimax asli obat pembesar penis terbaik.

  7. instafollowers says:

    Now Instagram gaining more popularity day by day. The more Instagram followers you have, the more effective you are. One day I’m looking for how to get free Instagram followers and guess what i got a webpage which have an online tool for generating unlimited followers for Instagram account.

  8. big thanks for writed article and i have blog but not good for sharing

  9. Kavita kumar says:

    Good news for all pokemon go players because it is now available over windows and you can play it on your phones easily just download pokémon go windows and give a real touch to your playing experience.

  10. CSR 2 says:

    Get it now csr classics hack and it will help you build your car the best car in the world.

  11. Internet phenomena in different parts of the world

  12. Really i appreciate the effort you made to share the knowledge. 

  13. This is really a great stuff for sharing. Keep it up. Thanks for sharing.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>