Dancing The Samba (part 2) - Making Conversation (
Page 3 of 7 )
You're already familiar with the "smbclient" utility - I used it when first configuring and testing Samba. But "smbclient" can do a lot more than just verify that your Samba installation is working as advertised - it's actually a full-featured FTP-like SMB client that can be used to perform file transfer and manipulation operations with an SMB server.
You can start up "smbclient" by providing it with a host name and share name to access.
$ /usr/local/samba/bin/smbclient //medusa/music
Password:
smb: \>
Once you're connected to that share, you can use standard commands to transfer files, read file information and perform other common file operations. Consider the following sample session, which should demonstrate most of the common operations:
smb: \> cd
Current directory is \
smb: \> mkdir temp
smb: \> cd temp
smb: \temp\> dir
. D 0 Tue Oct 8 17:09:18
2002
.. D 0 Tue Oct 8 17:09:18
2002
63882 blocks of size 32768. 1681 blocks available
smb: \temp\> put menu.php
putting file menu.php as \temp\menu.php (53.0271 kb/s) (average 53.0273
kb/s)
smb: \temp\>
smb: \> mput *.zip
Put file www.zip? y
smb: \> q
$You can obtain help by typing
smb: \> help
ls dir du lcd cd
pwd get mget put mput
rename more mask del open
rm mkdir md rmdir rd
prompt recurse translate lowercase print
printmode queue cancel quit q
exit newer archive tar blocksize
tarmode setmode help ? history
!
at the command prompt, or a one-line description of each command by typing "help" followed by the command name.
smb: \> help mkdir
HELP mkdir:
<directory> make a directoryIn case you're having difficulty connecting to shares, you can have "smbclient" generate debug data by adding the "-d" command-line option, followed by a number from 0 to 10; the higher the number, the greater the level of detail provided. Consider the following example, which demonstrates:
$ /usr/local/samba/bin/smbclient //medusa/music -d 5
Client started (version 2.0.6).
resolve_lmhosts: Attempting lmhosts lookup for name medusa<0x20>
getlmhostsent: lmhost entry: 127.0.0.1 localhost
resolve_hosts: Attempting host lookup for name medusa<0x20>
resolve_wins: Attempting wins lookup for name medusa<0x20>
bind succeeded on port 0
nmb packet from 127.0.0.1(137) header: id=15735 opcode=Query(0)
response=No
header: flags: bcast=No rec_avail=No rec_des=Yes trunc=No auth=No
header: rcode=0 qdcount=1 ancount=0 nscount=0 arcount=0
question: q_name=MEDUSA<20> q_type=32 q_class=1
Sending a packet of len 50 to (127.0.0.1) on port 137
read_udp_socket: lastip 127.0.0.1 lastport 137 read: 62
parse_nmb: packet id = 15735
Received a packet of len 62 from (127.0.0.1) port 137
nmb packet from 127.0.0.1(137) header: id=15735 opcode=Query(0)
response=Yes
header: flags: bcast=No rec_avail=Yes rec_des=Yes trunc=No auth=Yes
header: rcode=0 qdcount=0 ancount=1 nscount=0 arcount=0
answers: nmb_name=MEDUSA<20> rr_type=32 rr_class=1 ttl=496220
answers 0 char ...... hex 0000C0A8008F
Got a positive name query response from 127.0.0.1 ( 192.168.0.143 )
Connecting to 192.168.0.143 at port 139
write_socket(3,76)
write_socket(3,76) wrote 76
Sent session request
got smb length of 0
size=0
... and so on (snip!) ...One of the cooler (and also more annoying) things you can do with "smbclient" involves using it to send text messages across a network to Windows workstations. These messages appear on the target Windows workstation via the WinPopup utility. Consider the following example, which demonstrates:
$ /usr/local/samba/bin/smbclient -M medusa
Connected. Type your message, ending it with a Control-D
system is going down!
sent 25 bytes
$
When this message is sent to the Windows workstation named "medusa", it pops up as a dialog box on that machine (note that in order for this to work, WinPopup must be installed on the target system, and must be configured to accept and display messages).