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

smbclient (Samba)


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:

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

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?

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

Yeah, it's obsolete, clunky, insecure and broken, but people still use this stuff (Tony Lawrence)

This post tagged: