Using smbclient

The smbclient program is a tool for transferring files with a system offering an SMB share. It is particularly useful for transferring files with Windows systems that do not have FTP server software. smbclient acts like an FTP tool for SMB share files. Listing 9.11 illustrates this.

Listing 9.11: Using smbclient

$ smbclient //robin/temp -W sybex added interface ip=172.16.5.2 bcast=172.16.5.255 nmask=255.255.255.0 Password:

$ smbclient //robin/temp -W sybex added interface ip=172.16.5.2 bcast=172.16.5.255 nmask=255.255.255.0 Password:

alana1_

_0

jpg

A

6147

Sun

Jul

8

11

39

42

2001

alana2_

_0

jpg

A

8180

Sun

Jul

8

11

46:

56

2001

alana3_

_0

jpg

A

23296

Wed

Aug

8

09

37

24

2001

alana4_

_0

jpg

A

42857

Sun

Nov

25

16

50

42

2001

alana5_

_0

jpg

A

22456

Sun

Nov

25

16

53

00

2001

alana6_

_0

jpg

A

55847

Wed

Feb

6

16

00

20

2002

alana7_

_0

jpg

A

42799

Wed

Feb

6

16

10

50

2002

51795 blocks of size 131072. 11861 blocks available smb: \> get alana1_0.jpg getting file alana1_0.jpg as alana1_0.jpg (average 158.0 kb/s) smb: \> quit

51795 blocks of size 131072. 11861 blocks available smb: \> get alana1_0.jpg getting file alana1_0.jpg as alana1_0.jpg (average 158.0 kb/s) smb: \> quit

The smbclient tool is invoked by the smbclient command. The share that you're accessing is described on the command line using the Microsoft Uniform Naming Convention (UNC). The UNC format is IIserver/sharename, where server is the NetBIOS name of the server, and sharename is the name of the share.

If a share password is required, which might be the case if the server uses share-level security, it follows the UNC on the command line. In the Listing 9.11 example, share-level security is used, but the password is not provided on the command line, so the server will prompt the user for it.

Use the -U command option, and provide the username and password separated by a % if the server uses user-level security. If a workgroup name is required, provide it with the -W option, as shown in Listing 9.11.

After the username and password have been provided, files are sent and retrieved using exactly the same commands as FTP. If you can use FTP, you can use smbclient.

The smbclient program is the workhorse of the Samba client tools. It is not very elegant, but it is the basis for several other client tools that are shell scripts that use smbclient to get the work done. A more graceful way to integrate SMB server files into the Linux filesystem is with smbfs.

Was this article helpful?

0 0

Post a comment