APLawrence.com -  Resources for Unix and Linux Systems, Bloggers and the self-employed

smbclient (Samba)

2005/05/19

This is a Samba tool that's useful for testing Samba, doing backups to or from Windows shares, and similar tasks. For testing, the most common use is to list shares on a Windows machine or some other Samba server. Just do:



smbclient -L netbiosname
 

If you need to provide a user name, add "-U user". You can also supply a password either by adding it with "-U user%passwd" or by setting and exporting PASSWD, or by pointing it credentials file; see the man page.

For backups of PC shares, there's a "smbtar" shell script. It's just a wrapper for smbclient; read it to see how it works.

There's also an ftp-like interface. For example, here's a simple script that ftp's several directories using smbclient:

#!/bin/sh
export PASSWD
PASSWD=hpSj943xg
# choose backup file
DAY=`/bin/date +%u`
FILE="ahpbu"
case $DAY in
  1) FILE="ahpbu";;
  2) FILE="bhpbu";;
  3) FILE="chpbu";;
  4) FILE="dhpbu";;
  5) FILE="ehpbu";;
  6) FILE="fhpbu";;
  7) FILE="ghpbu";;
esac
for bufile in  database1 database2 
do
/opt/samba/bin/smbclient //bdcpub/$FILE  -U hp <<HERE
mkdir $bufile
cd $bufile
lcd /$bufile
recurse 
prompt off
mput *
quit
HERE
done
 


Got something to add? Send me email.





Increase ad revenue 50-250% with Ezoic


More Articles by

Find me on Google+

© Tony Lawrence



Kerio Samepage


Have you tried Searching this site?

Unix/Linux/Mac OS X support by phone, email or on-site: Support Rates

This is a Unix/Linux resource website. It contains technical articles about Unix, Linux and general computing related subjects, opinion, news, help files, how-to's, tutorials and more.

Contact us





After growing wildly for years, the field of computing appears to be reaching its infancy. (John Pierce)

Anyone who puts a small gloss on a fundamental technology, calls it proprietary, and then tries to keep others from building on it, is a thief. (Tim O'Reilly)







This post tagged: