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.
More Articles by Tony Lawrence © 2012-07-18 Tony Lawrence
The three chief virtues of a programmer are: Laziness, Impatience and Hubris. (Larry Wall)
Printer Friendly Version
smbclient (Samba) Copyright © May 2005 Tony Lawrence
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