By Marcel Gagné
This article was originally published in the July 2004 issue of Linux Journal.
It’s A Cross Platform Alright!
Note : Images have been scaled down to fit the pages. To see the full sized version, click on any of the images.
Yes, I admit it, François. That’s very funny. When I told you that this month’s theme was cross-platform development, I didn’t mean platforms that make you cross, though I can understand thinking of Windows as a cross platform. As amusing as those images are, I think the artwork you chose for the menus tonight might raise a few eyebrows, despite our, shall we say, sympathetic audience.
Speaking of which, I see that our guests have arrived. Welcome, mes amis, to Chez Marcel, home of exceptional Linux fare, one of the world’s greatest wine cellars, and the greatest customers in the world. Please, sit. Make yourselves comfortable. François and I were discussing the theme of this month’s issue, cross platform development and my waiter was getting a little rambunctious. It almost seems as though we should bring out a white Zinfandel for this, but luckily, we have none in stock. I think what we need is something with a little more attitude, a wine with a rich, flavorful serving of cherries, blackcurrants, and a finish that doesn’t stop. François, to the cellar, immédiatement! Bring up the 1992 Napa Valley Cabernet Sauvignon. Vite!
As many of you know, Windows is still very much a part of the average business IT department. Despite Linux’s obvious superiority, many of us must be able to move easily (or, at least, exchange information) between these two platforms and many desktops are still running Windows. That is changing, of course, but slowly.
Somehow, you managed to convince management to let you run Linux on your workstations instead of Windows. Maybe you are using your own notebook. Whatever the reason, you are now going to have to deal with the Windows workgroup or domain and the appropriate shared files and printers. Oui, mes amis, it is time to join the network neighborhood of somebody’s network places. While Jon in accounting isn’t particularly fond of his XP box, it’s part of his job and many important files are shared from that machine, files that are shared in the network neighborhood.
Ah, François, you have returned. Excellent. Please, fill our guests’ glasses. Merci, mon ami.
You might ask yourself how easy it is to take advantage of the network neighborhood. This is an interesting question considering how many file and print servers out there aren’t running Windows, but Linux, providing the file sharing experience through Samba. Consequently, it isn’t surprising that Samba client software tends to come as part of the standard installation on most modern Linux distributions. What that means is that you can connect to a Windows share on the network using the smbclient program.
smbclient -L sedna
That would produce a report of shares that looks something like this.
Domain=[ACCOUNTING] OS=[Windows 5.1] Server=[Windows 2000 LAN Manager]
Sharename Type Comment
--------- ---- -------
IPC$ IPC Remote IPC
Assuming that you had the permissions to view the Reports folder, you could connect to it like this.
smbclient //sedna/reports -U winuser
In the above example, I am connecting to a Windows XP box from my Linux workstation as user “winuser”. The system will then ask me for a password after which I will be at a Samba prompt that looks like this.
Domain=[ACCOUNTING] OS=[Windows 5.1] Server=[Windows 2000 LAN Manager]
From there, type help and smbclient offers up a list of all the things you can do while connected via the commands at your disposal. A number of them are obvious such as dir, copy, and so on. While this is all good, it’s not pretty in the graphical sense and you can’t use this while working in your graphical file managers or inside OpenOffice.org’s applications.
Whether you are using KDE or GNOME as your desktop environment, rest assured that all the tools you need to join the network neighborhood are right there at your disposal. Best of all, it’s extremely easy to do. Let’s start by taking a look at Konqueror.
Open up Konqueror (either as file manager or browser) and type the following in the Location field.
Samba servers or Windows machines advertising network shares will first appear in the browser window under their workgroup name (eg: ACCOUNTING, SALESGRP, etc). Look at figure 1 and you’ll see a Konqueror session with a two panel view (click Window on the menu bar and select Split View, Left/Right). In the left panel, we have the basic network browser view with three active workgroups. In the right-hand panel, I’ve clicked on the ACCOUNTING workgroup to show the computers that make up part of that group.
[ Figure 1, “Using Konqueror to browse workgroups” ]
To read, write, or otherwise make use of the files shared on those computers, double-click on the corresponding folder for that computer (François’ computer for instance. All of the available shared directories (or folders) are then visible (figure 2).
[ Figure 2, “Once connected, browsing is basic file manager navigation” ]
From here, it’s all classic drag and drop, graphical file manager browsing. By clicking (or double-clicking, depending on your configuration), I can go inside the cooking folder, locate the appropriate document and open it with OpenOffice.org Writer if I choose (right-click on the file, select Open with) and Voila!, I’m editing a document on a shared Windows resource.
Ideally, we don’t want to go through this whole navigation process each and every time. To bring a given network share a few clicks closer, simply bookmark the appropriate shared folder.
Over on the GNOME side of things, we have Nautilus. You will find the process very similar to what we just did with Konqueror. Start Nautilus and type the following in the Location bar.
Nautilus will then display the active workgroups on the network. (see figure 3).
[ Figure 3, “Nautilus in SMB network browse mode” ]
From there, you can double-click on one of the workgroups to select a computer. Then, from the list of computers, double-click on your choice and you can browse the individual resources offered (figure 4). Be aware that while you move around from computer to computer like this, you may occasionally be asked for a user name and password for that computer or even the specific folder.
[ Figure 4, “Windows and Samba shares are easily accessed” ]
As with the Konqueror example before this, you can save yourself a little time by bookmarking the folder of your choice. The problem with both of the suggestions I’ve made is that neither of them lets you permanently mount network drives. Accessing a particular folder requires that you do a little command line work, an easy enough process but not quite the point and click ease that Windows users on your network will want to see. Let’s have François refill our glasses while we take a look at a means to solve this dilemma. Mon ami, kindly do the honors for our guests.
For a more robust and flexible means of working in and with the network neighborhood, you simply must take a look at Smb4K, a super-classy SMB browser tool that is also flexible and powerful. Furthermore, it makes it possible to preview shares, mount shares locally (without the need to run as root), reconnect automatically on startup, and more. To get your copy of Smb4K, head on over to http://smb4k.berlios.de/index.php.
At the time of this writing, Smb4K was sitting at 0.3.2 release, but I found it a very capable package and definitely worth the time to investigate. Binary packages for Debian, SUSE, and Fedora are available from the site as is the full source. Building smb4k from source is as easy as the classic extract and build five-step.
tar -xzvf smb4k-0.3.2.tar.gz
su -c "make install"
When you have installed the package, run the program by calling smb4k. As soon as you start Smb4K, it scans the network looking for active shares. You can fine tune the functionality, including options like whether you want shares to be automatically reconnected by clicking on Settings in the menu bar and selecting Configure Smb4K. The graphical interface is intuitive and easy to navigate and the package is very easy to use.
The display is divided into a left hand side navigation panel where workgroups, computers, and shares can be listed and navigated. To mount a share, right-click on it and select mount. If you would rather see what you are getting into first, choose Preview instead.
[ figure 5, smb4k.tif goes here : caption reads “Smb4K : Could this be the ultimate SMB browser?” ]
Mounted drives appear in the top right hand window as drive icons. Double-clicking on one of the drive icons calls Konqueror. If you run the df from the command line, you’ll see that the drives are now mounted for your use in your own home directory under an smb4k directory prefix. For instance, in the example in figure 5, the listing looks like this.
Filesystem Size Used Avail Use% Mounted on
//SEDNA/Reports 4.0G 3.0G 1.1G 75% /home/marcel/smb4k/SEDNA/Reports
//FRANCOIS/wine 13G 8.8G 3.3G 73% /home/marcel/smb4k/FRANCOIS/wine
Now, any of my applications, whether KDE, GNOME, shell-based, or anything for that matter, can access the shares. Being part of the neighborhood has never been easier.
Mon Dieu, mes amis, closing time has come so quickly. François, would you be so kind at to refill our guests’ glasses a final time. We certainly don’t want anyone going home cross, and with the items on today’s menu, the neighborhood’s doors will all be open to you. That’s certainly something to smile about. Until next time, mes amis, let us all drink to one another’s health.
A votre santé! Bon appétit!
KDE and Konqueror