Letters

Is 54G as Good as 54GL?

Regarding Mick Bauer's “Building a Transparent Firewall with Linux” series in the August, September, November and December 2010 issues: is the 54G*L* a must? I have been upgrading regular 54Gs successfully with DD-WRT for quite a while. Would you say that once OpenWrt is on the device, 54G is as good as 54GL? I have a few of those here, mostly v.2 and v.3, which is why I am asking. Looking forward to your reply.


Lee

Mick Bauer replies: Excellent question. The L is Linksys' way of indicating that the device is designed to run Linux, which means you have the manufacturer's assurance that it's possible to load OpenWrt (or DD-WRT or another OpenWrt derivative) and that the device's particular wireless chipset, bridge circuitry and so forth will be recognized under Linux.

However, OpenWrt runs on many other Linksys devices, not just those with an L in the model number. The real measure is the device's status in the OpenWrt Table of Hardware (wiki.openwrt.org/toh/start) and, of course, your own experience. If you've had success running DD-WRT or OpenWrt on a Linksys WTR-54G, obviously it works!

Note that early versions of the 54G shipped with Linux firmware; the WRT54G was the very first device OpenWrt ever supported.

Tech Tips, September 2010

Tanmay Mande's “Download Bandwidth Usage” brought back the excitement of my younger MS-DOS computing days. Like my wheat-eating rodent, which neither Ubuntu nor Fedora now catches, I am getting a little long in the tooth. I am a lone SUSE/Puppy/Slackware user eschewing the 4M Company (Mighty Monopolist Mogul Microsoft). My tooth length means I have absolutely no desire to re-invent the wheel by learning the myriad *nix programming languages and writing my own utilities like Tanmay's download measurer, although if I could find a Bash tome in a second-hand bookshop, learning Bash scripting is worth the effort. After much delay and hassle getting my window into CyberEarth open, I couldn't find a down-/upload meter addon for FireFox. When running SUSE, the download iptables setup script has to be run in a root text window each time after booting my router; boot.local doesn't work as Tanmay implies. The newer distros, with the exception of Slackware, are no longer DIY-learn-as-you-go-along Linuxes, having become too complicated and WinDoze-user friendly. Tanmay Mande, thank you for making my day!


Wilfred Tritscher

Tweeting from a Script

In the November 2010 issue of Linux Journal, Jamie Popkin mentions using curl to post to Twitter to alert him when someone cancels a user session on his children's computer [see Jamie's article “Controlling Your Linux System with a Smartphone”]. Unfortunately, this method of posting to Twitter no longer works, as it has moved to the OAuth spec. Luckily, a Google search on “Twitter OAuth command line” returns several sites that explain how to get it working again.


John Grafton

How to Get My Netflix Fix?

Okay, it bugs me to no end that Netflix does not work on Linux. Now answer me this, which really boggles my mind. Why is it that the Roku device, which runs on Linux, can stream videos, but I can't do the same thing in Ubuntu 9.10? There must be a way to get my Netflix fix without having a dual-boot PC.


jpm1973

It is absolutely true that the Linux-powered Roku can stream Netflix, but the Linux desktop cannot. I don't know of any way to “fake” it either. I've tried both Wine and whining, and neither seems to help. Hopefully, Netflix will fix this travesty, but I'm not terribly hopeful.—Ed.

Spaces in Filenames

Love your magazine. I am an IBMer, and a lot of us are moving to Linux (mainly because Windows XP is 32-bit, and Linux is 64-bit).

I had a question on Dave Taylor's article “Scripting Common File Rename Operations” in the November 2010 issue. I like this script, but does it handle spaces in filenames?

Here is a common script that I have, but it fails because of spaces:

for n in $(find . -name ".copyarea.db"); do rm -f $n; done

None of the Linux commands like spaces very much. And, when I try to wrap things in double quotes, that doesn't work either. Any ideas? Thanks.


Doug

Dave Taylor replies: Doug, you're absolutely right. UNIX/Linux does not like spaces in filenames. It's a pain, to say the least.

One easy solution that works much of the time is simply to ensure you surround any occurrence of a filename with double quotes in your scripts (not single quotes, those would stop the “$” variable from being expanded). So, try this:

for n in $(find . -name ".copyarea.db"); do rm -f "$n"; done

You also should look at the -print0 option in find, and consider a non-for loop, like this:

find . -name ".copyarea.db -print0 | xargs -0 /bin/rm -f

I've not tested it, but that should do the same thing and considerably faster! Cheers, and thanks for writing.

Finding Program Files in Your Path

I often have wondered if there was a command on my system that had to do with something I was doing and would end up manually listing the directories and grepping for it. I put together a little script to make this easy and called it findip for find-in-path. It makes looking, for example, for all program files having to do with volume—that is, findip volum lists all files with volum in their names. Here's the script:

# find in path ignore case
NAME=$1
find $(echo $PATH|tr ':' ' ') -iname "*${NAME}*"
exit 0

Thanks for a very helpful and interesting publication.


Alex

I love the flexibility of Linux scripting. Congrats on bending the command line to your will!—Ed.

Another Way to Count Files

Regarding Dave Taylor's November 2010, Work the Shell column: another way to count files and avoid grepping away the “No such file” error message is to use “echo pattern*”:

pat=$1
matches=$(echo $pat*)
if [ "$matches" != "$pat*" ] ; then
  matches=$(echo $matches | wc -w)
else
  matches=0
fi



Michael Eager

Dave Taylor replies: True. I never really think of using echo in this sort of situation. Good idea!

Happy 200th Issue

It might be a bit late now, but better late than never. Anyway, happy 200th issue! What a milestone! I think every issue is a milestone reached, but the next big ones I'm looking forward to are the June 2013 and July 2014 issues. The first is for LJ's 20th anniversary, and the other is for the 0x100th issue (I don't always use my ten [1010B] fingers to count). I might be one or two issues off, but it doesn't matter. I enjoy every single one!

Some people write songs or poems to celebrate milestones, but other people like me write code. This one is for you:

issue = 200L;
while (1 == 1) {
    publish(issue);
    if (mod (issue, 100L) == 0) {
        celebrate();
        bragAbouIt();
    }
    enjoy(issue);
    issue++;
}



JSchiavon

10 PRINT "Thank You!"
20 GOTO 10

—Ed.

Poor Practices Taught in Work the Shell?

I try to ignore most of Dave Taylor's Work the Shell columns, but I find it hard to keep silent when I see repeated examples that teach poor bash programming practices.

In the November 2010 column, all of the examples fail to quote arguments passed to commands like mv, which is sure to blow up the instant the script is run on a file with a space in the filename. Additionally, the same example needlessly calls sed, when bash parameter expansion in the style “yy${name#xx}” or “${name/xx/yy}” would do fine. Why not teach the readers these useful features of bash?

Additionally, the author goes to great pains to handle the case where no files match the pattern, including spawning three separate processes and filtering on the error message output of one of those commands. A much better practice in bash would have been simply to enable nullglob with the command shopt -s nullglob, which allows glob expansion to expand to the null string. Using nullglob would have been a simple, more efficient and more reliable way to avoid any iterations of the loop if there were no matches.


Bob Bell

Dave Taylor replies: Thanks for your note, Bob. It's inevitable that if you get two programmers in the room, there'll be at least three opinions floating around. Your “poor practices” is my constant demonstrations of “get it done, get on with your job” efficiency. Having written books about programming, I know that you can spend a huge amount of time fine-tuning any given code snippet to make it optimal, but in the real world, in a production environment—particularly with shell script programming—it's about solving the problem. Often the solution is lazy, inefficient or even partially broken. But if it does the job, you can move on to the next task. Agreed?

In terms of filenames with spaces in them, you're right. I have been involved with UNIX and Linux for so long that I feel physically ill if I put a space in a filename (only partially kidding!), so I often forget to ensure that my demonstration scripts work for filenames that include spaces. Frankly, Linux is not a very spaces-in-filenames-friendly environment anyway.

Again, thanks for your note. As always, I encourage readers to use what I write as a launching platform, a place to learn more about shell script programming, get ideas for different ways to solve things and enjoy a puzzle solved, even if the solution isn't necessarily a) the most optimal or b) how you'd do it!

Wi-Fi on the Ben NanoNote

I was reading your journal today in the library, and I read among other things Daniel Bartholomew's article on the Ben NanoNote in the October 2010 issue.

Here are some links where you can see that some microSD-Wi-Fi adapters work with Ben NanoNote: en.qi-hardware.com/wiki/Ben_NanoNote_Wi-Fi and www.linux.com/news/embedded-mobile/netbooks/296251:a-review-ben-nanonote-gets-small-with-embedded-linux.

So, the device also can be used, for example, for Web surfing, but it would be better if one managed to embed a USB-Wi-Fi adapter into the device (not so impossible if the Ben NanoNote does have a USB-host on it).

Thanks for the article. It was enjoying to read it and made me happy for those people who make things (especially hardware) copyleft.

I first will try to hack my (Linux-based) Eee PC, then maybe try hacking on a Ben NanoNote (when more hacks are described on the Internet). Thanks for the fine journal!


Oussama

Daniel Bartholomew replies: Yes, there are some Wi-Fi adapters that work with the Ben NanoNote, but based on what I've read, you need to recompile the kernel to include the appropriate drivers, and there are issues (hotplug not being supported yet is one). I agree that it would be much better to have a wireless chipset and antenna integrated into the NanoNote. I look forward to seeing the second generation of the NanoNote and hope wireless networking is part of it. That said, there's nothing stopping people with the appropriate skills from creating their own version of the NanoNote and to include whatever hardware they have the ability to include (wireless or otherwise). That is what makes copyleft hardware so awesome. Thanks for your comments and happy hacking!

rename.sh

In the November 2010's Work the Shell column by Dave Taylor, I read “ls -l actually generates an error message: ls: No such file or directory”. This is not always true. On my PC, it generates an error message in the Dutch language (I live in Belgium, and Dutch is my native language): Bestand of map bestaat niet. So, the line grep -v "No such file" doesn't work here. I think a LANG=C should be added.

Also, I have downloaded the complete rename script (10885.tgz), but there are some errors in it.

For example, at line 14 of the rename.sh-script, I see echo ". I think there is a second quote missing. There is also a “case” without an “esac” and a “do” without a “done” in the script. I think that part should be something like this:

for i; do
 case "$i"
 in
  -n ) renumber=1 ; shift ;;
  -p ) fixpng=1   ; shift ;;
  -t ) doit=0     ; shift ;;
  -- ) shift ; break ;;
 esac
done

After these changes, the script is working for me.


Jan Wagemakers

Dave Taylor replies: Thanks for the reminder about the issues associated with localized Linux! I can't explain why the code was missing some elements though. Might be a transmission hiccup. It worked on my test system before I sent it in. Really.

Giving Up on Linux

The reason I write is that maybe you can change my mind. I've been a Linux user since 2005. First Mandrake, then openSUSE and the last Ubuntu 10.04 (since 6.06). I fought for open-source software, and I honestly believed in it, until I was fed up with trying to make Linux work for me the way I needed and was spending more time researching, building and compiling, than actually doing what I needed to do.

For basic Web surfing and typing documents, it's okay. The stability and security of Linux is remarkable, and so on. When it came to movie editing, I had a lot of problems. After that came the problem of ripping CDs. It was taking so long that I had to go back to Vista to rip and transfer the data to Linux. When I tried to rip it to Ogg files, my music did not sound right. It sounded as if there were sequences missing. Later, it seemed that I often was losing the metadata of my MP3s, and for me, that was important, because I'm converting sermons for my church from CDs to MP3s and uploading them to the Web site. Finally, burning CDs with Brasero was too buggy, so I used K3B instead. Again, for writing simple data it was good, but when I wanted to burn a sermon on a CD, instead of the metadata or information that was supposed to appear, it was some foreign Asian language.

I could have lived without the movie editing, but for me, CDs, MP3s, metadata and CD-burning problems are too much. So you see, I was spending more time trying to fix these problems than actually getting my work done. So, unfortunately, I had to switch all of my work back to Windows Vista.

I can't believe what I'm saying, but Windows Vista does the job right, the first time.

Maybe I should try another distro. I don't know anymore. I do not want to go through another process of learning a new distro and spending hours again trying to fix it. I was very sick the past year and a half, so I'm exhausted, and I need things to just work sometimes.

So if you can help, I would appreciate it. If not, it's okay, but my ride in the Linux community is over.


JF

First, I will freely admit I feel your pain. I struggle with movie editing (a big part of my job here at Linux Journal), and at times, I feel like I'm spending more time preparing to work than actually working. Since Linux is developed by people basically for themselves (that's a gross generalization), often the most common things work the best out of the box.

Sometimes I find that manipulating the underlying command-line tools via shell scripts works better for me. This is especially true with video format conversion and so on. Although I personally haven't done much with CD burning, it's possible the same is true.

If you're still interested in trying another distro, perhaps one aimed specifically at media creation may be tweaked a bit better for your needs. Ubuntu Studio is one of those options, but there probably are others as well.

Finally, I'm not sure if you're familiar with the support available on-line for such things. You mentioned Ubuntu is your distro of choice lately, and the Ubuntu forums are really great for getting support from both peers and developers. In the end, of course, it's up to you to use whatever system meets your needs. We won't judge you!—Ed.