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

smbclient (Samba)

© May 2005 Tony Lawrence

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.

(OLDER)    <- More Stuff -> (NEWER)    (NEWEST)   

Printer Friendly Version

-> smbclient (Samba)

Inexpensive and informative Apple related e-books:

Are Your Bits Flipped?

Take Control of Apple Mail, Third Edition

Take Control of Preview

Take Control of iCloud, Fifth Edition

Take Control of iCloud

More Articles by © Tony Lawrence

Printer Friendly Version

Have you tried Searching this site?

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

Printer Friendly Version

The three chief virtues of a programmer are: Laziness, Impatience and Hubris. (Larry Wall)

Linux posts

Troubleshooting posts

This post tagged:



Unix/Linux Consultants

Skills Tests

Unix/Linux Book Reviews

My Unix/Linux Troubleshooting Book

This site runs on Linode