You can easely donwload mp3 and free ringtones
...making Linux just a little more fun!
Hello kid ..etcA pal of Jimmy's writes him personally - here's just the techie part... -- Heather
so every thing is up in the air.. but heh thats life... As Douglas Adams said "I love deadlines.. I love the wooshing noise they make as they fly by".
If you could get me an answer on that by any means necissary I would be grateful.
Forgive any mistooks as I only stopped drinking abot 6 hours ago...
So how you been keeping.....
[Jimmy] Not too bad. Much better if my PC'd stop crashing every time I try to send an email.
One quick question before before we get into all that lot though....
I need help with grub / booting a linux kernel.. I will describe it to you..
I need it for my forensics workstation. I need to mount entire disks on /dev/loop
See attached philip_obrien.grub.conf.txt
[Jimmy] First off, I've never had to mess with grub before, and I'm only guessing here, but I'd say the problem is that you're trying to run an older kernel version from the same partition as a newer version. Sure, modules from the different versions will live happily together, but do you have a version of modprobe for both 2.4 and 2.6? Does your modules.conf have settings for 2.6 that don't work for 2.4?
If you want, I can forward this to the Answer Gang, where you're much more likely to get a knowledgeable answer, that is, if you don't mind seeing your question published.
Now back to the happy stuff....
And that, dear readers, brings us to you. Anyone interested in taking a shot at the question, submit your note to The Answer Gang in however long or short a fashion you'd like. -- Heather
Problems with tcsh scriptingHi,
I have a number of issues with tcsh (not my choice..) shell scripting I need help with.
Basically I'm writing a shell script that automates a long setup procedure. This top-level script is in bash, however the bulk of it is comprised of commands that are fed to a program which is, in essence, a tcsh shell. I've achieved this by using the << redirector. I need help on two points:
1) Is there any way of suspending input redirection, taking input from the keyboard, and then resuming input from the tcsh script?
[Ben] There is, but it is Fraught With Large Problems. I'm not that familiar with TCSH, but I've just had to do that in Perl - essentially, I was writing a Perl version of 'more' and had to answer the question of 'how do you take user input from STDIN when the stream being paged is STDIN?' It requires duplicating the STDIN filehandle... but before you start even trying to do it, let me point you to "CSH Programming Considered Harmful" - Tom Christiansen's famous essay on Why You Shouldn't Do That. If it's not your choice, then tell the people whose choice it is that They Shouldn't Do That. The task is complex enough, and has enough touchy problems of its own, that introducing CSH into the equation is like the Roadrunner handing an anvil to the Coyote when he's already standing on shaky ground over a cliff.
To give you some useful direction, however - the answer lies in using 'stty'.
2) There comes a point towards the end of the script when two shell
scripts are run simultaneously. These shell scripts open up individual
xterm windows to run inside. I'm wondering, is there anyway of having
the tcsh script monitor stdout of one xterm, and upon the output of a
certain piece of text, echoing a command into the stdin of the other
xterm?
Any insight or knowledge on the matter would be very much appreciated.
I hope I have provided sufficient details.
Aengus Walton
[Ben] You have - from my perspective, anyway.
If someone would like to write an article on interesting shell tricks with tcsh specifically, check out the Author Guidelines, then drop a line to our articles@ staff. -- Heather
PyGtk Deprecation errorHi,
could any one kindly tell me what is PyGtk Deprecation error ? I see the error when ever I try to compile IceWMCP which is based on PyGtk. thanks for your time.
Disappearing USB printerOur readers are welcome to chime in on this thread-- Heather
Okay guys (and gals) ... I've been lurking for too long and have to ask
a question
I've got a HP Laser 2550 connected via USB. Using Mandrake 2005LE which has a 2.6.11 kernel. Using CUPS for the printer.
[Karl-Heinz] I've some networked lasers and one on the parallel port here...
The printer works fine ... but, sometimes (after a fairly long uptime) printer commands just hang. Of course, this usually happens when my wife is the room and I'm trying to impress her with the power of Linux, etc.
[Karl-Heinz] ...and see occasionally the same. In our case the printer get's into some error state and cups automatically disables the queue but still accepts new jobs. Usually it's enough to to restart/reenable the cups queue by going to the web-configuration http://localhost:631/ and disable/enable the printer or on commandline (maybe as root) with /usr/bin/enable printername . You can't use just "enable" as that's a bash builtin which will not affect your printer at all (great command naming that!).
[Ben] I always have to remind my students in the shell scripting classes that "/usr/lib/rsh" is the correct invocation for the restricted shell in Solaris; plain "rsh" is the "remote shell" from the "r" utilities.
Back in those early days, all good *nix program names were four characters long; assuming the standard naming convention, in which only lower-case letters, numbers, and the underscore character are valid, you were restricted to 37^4 possibilities (gosh, only 1874161 possible programs - THAT must have been an incredible disappointment to new programmers trying to break into this highly restrictive field!) Now, however, with 255 characters for length and almost everything except '/' usable (although not necessarily a good idea!), when you could have program names like
This is the gadget that I use to write letters and send them to my Grandma
I find that kind of behavior somewhat boggling.
Was this a *nix restriction, or just a convention for lazy people who really didn't want to use ANY extra keystrokes?
[Ben] Y'know... I'm not sure. I think it was a sort of a generally agreed-upon convention, like "thou shalt name all your resource configuration files with a name ending in 'rc'" rather than a technical restriction. Anyone have input on this?
[Jimmy] From "A Brief History of the 'ls' command" (http://linuxgazette.net/issue48/fischer.html)
|
............... When CTSS was superseded by Multics, the listf command was renamed to list, which could optionally be abbreviated to ls. ............... |
Presumably the Bell Labs folks tended to use only the abbreviated versions and the naming convention stuck.
Also, according to Wikipedia's article (http://en.wikipedia.org/wiki/Bourne_shell), versions of Unix prior to V7 had a 127 byte limit for 'parameter lists'.
The files do end up in the cups spool directory. But, just sit there. The 3 or 4 times this has happened I've just rebooted and all is fine. But, that's a pretty dirty way to do this.
[Karl-Heinz] Could you check if it's just cups or the actual USB layer? What's in /var/log/messages, /var/log/cups/* ?
I do use a camera and mp3 player as well. But I really haven't seen a correlation between the printer problem and other USB usage. I sort of suspect that USB ports are being reassigned behind my back, but the printer is always powered on ... so that doesn't make sense.
Any ideas?
[Karl-Heinz] If it's really the USB layer you should find some hints in the logfiles.
Norwegian Minister: Proprietary Formats No Longer AcceptableWe had a note in News Bytes a couple months ago on this, and I suppose we could have commented then, but it's worth noting: governments are getting tired of being tied up by their own documents, there's better uses for red tape than that-- Heather
Full story at
http://www.andwest.com/blojsom/blog/tatle/agenda/2005/06/27/Norwegian_
Minister_Proprietary_Standards_No_Longer_Acceptable_in_Communication_with_Government.html
(also available at http://tinyurl.com/axgga)
Home Folder Server tweaksIn issue 101, Avinoam Levkovitch published an article entitled "Home Folder Server For WIndows Clients". Unless there's another way, his script looks like a good solution for me, as I'm trying to automatically create users on a sendmail server from entries in a Windows 2003 Active Directory. I can't locate the author, am by no means a coder, have a couple of questions, and so thought I'd ask.
First, Avinoam's script:
See attached home-folder.sh.txt
Now, my questions:
1. My windbind separator is "\". However, I don't want that (that is, the
domainname, as in "domainname\username") to be the home folder name. I just
want it to be the username. Does the script strip out the domainname, or
must I tweak it? If so, how?
2. There are certain users for whom I don't want to create home directories. These include all system accounts and those ending in $. How can I accomplish that?
Thanks!
Diggy
Booting Knoppix from a USB Pendrive via Floppy (obsolete!)[Ben] [ forwarded from off-list, with Jean-Luc's permission ]
Ahem, well...
Sorry if this bothers you but the whole trick you describe in
http://linuxgazette.net/116/okopnik1.html
does not work anymore since 3.8 (you did this in March with 3.7 didn't you?) because the kernel image alone is now larger than the whole floppy capacity.
[Ben] That's what I understood; one of our authors, Edgar Howell, was trying to do what I described, and reported exactly that.
In 3.9 there is not even a choice between 2.4 and 2.6 within the /boot/isolinux/ directory there is only one minirt.gz and one linux kernel image, no minirt24.gz/linux24
Anyway this trick was just more or less a duplicate of the mkbootfloppy script from Klaus Knopper which created TWO boot disks (one for primary booting, one for rebooting from a CD or CD image via an initrd). Given that the floppy space is now too short he didn't even bother to port it since 3.8
[Ben] I wonder if it's possible to make up a boot floppy that just fires up some minimal kernel with a USB module, then does a pivot_root() to the first detected USB device? I don't have the time to experiment with it these days, but sometime soon I'd like to play around with the idea.
Some REALLY SHARP hackery is now needed to boot from a non El Torito environment but if Klaus himself didn't bother or found out...
The cheapest trick is probably to buy a $15 ATAPI CD just for booting
[Ben] It's about 10X - 20X that amount for a laptop CD-ROM, though.![]()
[Sluggo] You got the frowny the wrong direction.![]()
So desktop CD-ROM drives are now as cheap as floppy drives? That's one more nail in the coffin for boot floppies.
[Brian] Yes, and every time that I build a system, and think I can get away without installing that "legacy" floppy drive, I remind myself that I have always, always, always found a need, so I install it anyway.
[Sluggo] My current computer has a micro-ATX case with no room for a floppy drive. That has weaned me off it.
[Brian] So how do you handle BIOS updates?
[Sluggo] I've never updated my BIOS. I get a new motherboard every few years to go with a faster chip. I've only had a floppyless computer since December, when I upgraded from 450 MHz to 2.88 GHz. Now that I can compile Gentoo in a few days, run KDE with reasonable speed, and boot any distro I want, I don't know what would induce me to upgrade again. Especially now that the power consumption/heat rates have begun to catch up with the CPU speeds. I don't get peripherals until a couple years after the technology comes out (and often much longer), so who knows when I'll need something my motherboard can't handle. There are two annoyances with this motherboard:
- I had to jumper my 40 GB hard drive to a compatibility size to get the BIOS to recognize it. This was surprising given how new the motherboard is. I resigned myself to live with it, then happily discovered that Linux sees the whole 40 GB anyway.
- It won't boot with GRUB. But that's the case with a lot of motherboards, and LILO still works fine even if it's not as cool.
[Jason] Hmmm...what is a case where you'd want to update your BIOS? What is the BIOS used for these days other than bootstrapping?
[John] You might be surprised. It's tied into the chipset of the mobo, so affects things like apic, and a host of other things that aren't necessarily configurable in the BIOS setup. After flashing the BIOS on my laptop, both fans became functional, instead of just one.
[Sluggo] Bootable CDs have been enough to install/rescue Linux distributions. I bought a USB stick for transporting files, then gave it to my mom for backups and used my camera instead. The main problem is you can't just make somebody a floppy and let them keep it; USB sticks are too expensive for that. You can burn a CD but it's less convenient than mount/cp/umount -- plus they have to throw it in a landfill when they're through. Hmm, maybe I should give them a CD-RW so they can reuse it.
[Brian] The usual culprit is a flash BIOS update that runs either as a windows executable (sorry, I'm not going to entrust a BIOS update to Wine), or as a DOS-based app from a custom boot floppy. Now I could go to the trouble to get the image booted off of a CDROM, but if I do that ONCE per system, it costs me more (in my time) than buying and installing the floppy to begin with. The day I have to buy a motherboard without a floppy ... Well, I'll probably end up with a USB floppy drive that I can shuttle system-to-system, and do it that way. Or I suppose that an ELF executable wouldn't be out of the realm of possibility, eh?
[Peter] I have some across some USB floppy drives, and it turns out they're not so useful in the linux context, given that they show up as /dev/sda rather than /dev/fd0. I guess a similar problem might affect Microsoft software which hasn't been updated to cope.
Cheers,
Jean-Luc Delatre
P.S. I didn't have the problem with USB but with a SCSI CD not supported by my BIOS
Anyone with either: 1. more answers regarding knoppix (or maybe other live CDs) when your machine has no choice but to boot from floppy, or 2. notes about success using usb floppies as a boot device, feel free to chime in with mail to The Answer Gang-- Heather
using public nameservers for staying connectedThis is a small addition to Ben's article "Staying Connected" (http://linuxgazette.net/115/okopnik.html ). He has a nice script for finding a working a working dns server. OpenNIC has a list of public dns servers (which honour requests from any client) available here http://www.opennic.unrated.net/personal.html or at the end of the page here http://www.opennic.unrated.net/public_servers.html .
Hope this is useful. Cheers
[Ben] Well, let's see -
# Print only the last set of servers
ben@Fenrir:~$ GET http://www.opennic.unrated.net/public_servers.html|perl -wlne'
if(/\bns[^\s]+/){@a=()if$f;@a=(@a,$&);$f=0}else{$f=1}END{print for@a}'
ns1.de.opennic.glue
ns1.jp.opennic.glue
ns2.jp.opennic.glue
ns1.nz.opennic.glue
ns1.uk.opennic.glue
ns1.la.us.opennic.glue
ns1.phx.us.opennic.glue
ns1.sfo.us.opennic.glue
ns1.co.us.opennic.glue
So far so good - BUT:
# I've saved the above list in "$list" ben@Fenrir:~$ for n in $list; do host linuxgazette.net $n; done ns1.de.opennic.glue does not exist (Authoritative answer) Error in looking up server name ns1.jp.opennic.glue does not exist (Authoritative answer) Error in looking up server name ns2.jp.opennic.glue does not exist (Authoritative answer) Error in looking up server name ns1.nz.opennic.glue does not exist (Authoritative answer) Error in looking up server name ns1.uk.opennic.glue does not exist (Authoritative answer) Error in looking up server name ns1.la.us.opennic.glue does not exist (Authoritative answer) Error in looking up server name ns1.phx.us.opennic.glue does not exist (Authoritative answer) Error in looking up server name ns1.sfo.us.opennic.glue does not exist (Authoritative answer) Error in looking up server name ns1.co.us.opennic.glue does not exist (Authoritative answer) Error in looking up server name
So - after reading the site a bit more, it turns out that these are Not Just Plain DNS servers; you've got to be running BIND in order to use them, unless I missed something. Makes them less than useful to a fellow who's just looking for name resolution...
Duh!
Sorry about the half-researched tip.
[Ben] Hey, man - that's what we do here, backstop each other. If I mistype some critical $thing, it's nice to know that (chances are) somebody here will catch it. 'Sall good - thanks for giving it a shot.
Subversion backendsAs is all too common with Subversion, LG's repository got wedged with a stale lock for the upteenth time.
% svn update svn: Berkeley DB error while opening environment for filesystem /var/svn/linuxgazette.net/db: DB_RUNRECOVERY: Fatal error, run database recovery svn: bdb: fatal region error detected; run recovery
[Ben] Due to the odd perms (particularly the 'group' settings), you can delete the files, but can't "chmod" them. In the above case, there's usually one file with the wrong UID or GID ('ls -l' shows the odd one); I just copy it to my ~, then copy it back (overwriting the original), then run 'svnadmin recover'. I used to have a script to automate this somewhere...
Our host runs a cron job that tries to fix these things. -- Heather
Subversion 1.1 has a new file-based storage backend that's immune to the BDB wedging problem. Another site I use switched to it, and said it was easy to dump the repository from the old system and restore it in the new one with history. Have TAGgers had any good/bad experiences with the new FSFS? Is it worth switching LG to it?
http://svnbook.red-bean.com/en/1.1/ch05.html#svn-ch-5-sect-1.3
[Ben] Might be nice; right now, it requires me to be available (or someone else who is familiar with SVN's quirks) if anything breaks, and minimizing SPOFs is always a good idea.
[Heather] On the cheerful recommendation of our host (more notably, the lack of complaints from otherwise noisy clients of his that have switched) we will be switching to this backend midmonth, after we publish.
TAG blogrollTAG members' blogs are getting more and more mentions, so I rolled up an OPML file (blogroll, whatever) for possible inclusion in this month's 'Gazette Matters' section. (It'd probably be nice to have some sort of static location for an updateable file, but I'll worry about that next month).
Comments?
If anyone wants in, fill out the template:
<outline title="" description="" xmlUrl="" htmlUtl=""/>
If anyone wants out, just say so.
See attached tag.opml.xml
[Heather] I don't 'blog, I just occasionally pipe in on the TAG blurb about what's going on in the rest of things. But I do read them. Thanks, Jimmy!
*sigh* another disaster, another nose count...As an editor I have to say, this is not the kind of message I enjoy having to send out, much less that we've had to send out what seems like so many times in the last year.
[Ben] [sigh] Yeah. Dammit.
Nonetheless we cannot in good conscience fail to say it.
Could those among our scattered crew who live in the waterlogged zones under or near the hurricane's path please report on your successful escape? Thanks, and our hopes go out to you - and everyone out there.
[Ben] The bad part of it is that we don't have any location information on people other than country (at best.) Those who are in trouble are not likely to respond; those who can respond - and I don't mean to minimize them, but net access isn't a survival necessity - are probably in a lot less trouble than they could be. Perhaps we should start collecting people's missile addresses, for future use...
[Jimmy] I published mine already:
<foaf:based_near>
<geo:Point>
<geo:lat>52.6796</geo:lat>
<geo:long>-7.8221</geo:long>
</geo:Point>
</foaf:based_near>
Google Maps is a great way to find out your own location.
[Ben] One of our mirror maintainers, Jim Pierce (who also happens to be a net.friend from a long time ago) has reported in; he's safe, 400 miles inland at his sister's house... but his house is most likely destroyed.
My heart and my best wishes go out to those who are suffering. Kat and I are looking at charities to which best to contribute; for the moment, we seem to be zeroing in on Red Cross.
I saw this on one of the freenode channels I hang out in; my clock's set to Pacific.
16:57 <@dangle> "****ALL RESIDENTS ON THE EAST BANK OF ORLEANS AND JEFFERSON
REMAINING IN THE METRO AREA ARE BEING TOLD TO EVACUATE AS
EFFORTS TO SANDBAG THE LEVEE BREAK HAVE ENDED. THE PUMPS IN THAT
AREA ARE EXPECTED TO FAIL SOON AND 9 FEET OF WATER IS EXPECTED
IN THE ENTIRE EAST BANK. WITHIN THE NEXT 12-15 HOURS****
16:57 <@dangle> Jeff Parish President. Residents will probably be allowed back
in town in a week, with identification only, but only to get
essentials and clothing. You will then be asked to leave and not
come back for one month."
16:57 <@dangle> that's rough
16:57 < klasikahl> jesus
16:58 <@dangle> that's from WWL
16:58 < klasikahl> they're under martial law to
16:58 < klasikahl> too
Roughly translated: when (not if) the pumps fail, a 9 foot wall of water will sweep down, expected within the next 12 to 15 hours... as of about 3 hours ago.
In yet another channel, a TV studio was reported as signing off planning to flee, when it started filling with water.
[Sluggo] On "The World Today 0200GMT" there's an interview with a WWL radio broadcaster in New Orleans, minutes before he left to seek refuge at their transmitter. http://www.bbc.co.uk/radio/aod/genres/news/aod.shtml?wservice/twt0300 (Aug/31/05, starting at 7:11 in the program)
One of the stranger twists of modern technology is that people in Louisiana were listening to this program (broadcast from London), and e-mailing in reports which were read on the program a few minutes later.
Who in the southeast are we missing? Ben checked in today.
[Ben] I'm in northern Florida. Jay, however, is in the south somewhere, IIRC, and this 'cane - not nearly at that intensity, but still - went over the south part of this state. Has anybody heard from him since? Jay, you out there?
[Breen] He posted this morning on NANOG.
[Ben] Thanks much, Breen; I'm glad to know it.
I've been hearing about cool things like soda pop plants turning off half the equipment so they can churn out cans of plain tap water, unpainted, to be sent into the rescue areas by the truckload.
The discussion on this topic turned to politics - things done, or not done, that led to things getting so drastic - more on that next month. -- Heather
2-cent-tip: Monospaced fonts on gmailHey, Well, thanks to a handful of different bloggers and Firefox hackers, I now can read my email on gmail in a monospaced font, the way it's supposed to be.
Grab URLid from http://extensionroom.mozdev.org/more-info/uriid
Stick this in your userContent.css:
body#mail-google-com .mb, textarea.tb {
font-family: monospace !important;
font-size: 12px !important;
}
And it Just Works(TM). Of course, since I know next to nothing about CSS, what I've done is basically a copy and paste of the tip given at http://blog.perldude.de/archives/2005/03/29/gmail-fixed-font except I changed "body#gmail-google-com" to "body#mail-google-com" because the former wasn't working for me, and I added the font-size bit. (Copied from some other page because otherwise I wouldn't know which CSS element to use.)
[Peter Knaggs] If you have the findutils package installed, this might help to find the right directory to put userContent.css:
locate userContent-example.css
For me, userContent.css seems to be happiest in the same directory as userContent-example.css, which is: $HOME/.mozilla/firefox/*.default/chrome/
Thanks for the tip!
[Peter is going to get another copy of this as I sent without first confirming that TAG was getting a copy. Funny thing, it's an email about how easy webmail is. And it is, if you can remember to click "Reply to all"]
Regarding editing your UserContent.css file, I've found ChromEdit to be helpful: http://cdn.mozdev.org/chromedit
I'm actually doing this stuff on a Windows box, but it involves gvim, so I hope we can count it as Linux-related. (I wish I was using Linux, so maybe that counts for something.)
There is a Window-only extension that allows you to edit text forms in an external editor:
https://addons.mozilla.org/extensions/moreinfo.php?application=firefox&category=Editing%20and%20Forms&numpg=10&id=580
Same thing, tinyurl'd:
Install it, go Tools > Extensions, select ExternalEditor, click Options, and changed the editor to gvim. Or whatever you want. (Or, if you like pain, you could leave it as notepad.) Then right click on a text form and select "edit". Only thing that annoys me is that Firefox freezes, so to look something up while composing an email, you have to save/quit, look it up, then open the editor again. Oh well, it beats trying to make properly quoted emails in a web browser text form.
[Jimmy] Check out the Launderette for more Google fun
Another 2 cent tip for youHi, guys.
Here's a little tip I gathered from some conversation going on in the alt.os.linux newsgroup a couple of months ago. I contacted the people involved in the news thread and they all agreed that I could submit the conclusions of the thread as a Two Cent Tip (with proper accreditation, of course). So, thanks to Michael Heiming and Chris F. A. Johnson, here's a Two Cent Tip for you...
Over in news:alt.os.linux, a reader posted a question that asked how to make Linux use "file associations" (sort of like MSWindows) so that the user just types the name of the data file at the commandline, and the sutiable application starts up and processes it. The example was wanting xmms to play an MP3 just by typing the MP3's filename at the command prompt.
This lead into a discussion amongst various alt.os.linux participants, primarily Michael Heiming and Chris F.A. Johnson, about "binfmt_misc", and how it could be used to satisfy MSWindow'ish "file associations". For those who don't know, you can "register" a command interpreter through a /proc entry, so that, when you try to run a file that needs that command interpreter, the system will start up the program for you. This is how Linux recognizes executable shell scripts in order to start the shell interpreter on them, and how it recognizes executable java byte code, in order to run the java interpreter on it, when you type it's name at the command prompt.
To use this feature, you need to mount the "binfmt_misc" pseudo-filesystem, so as root,
mount -t binfmt_misc none /proc/sys/fs/binfmt_misc
(or add the appropriate line to your /etc/fstab, and have it mounted automatically at the next boot). Now, (again, as root) tell Linux what interpreter to use by "echo"ing an association string into the /proc/sys/fs/binfmt_misc/register pseudo-file. In this case, we want to the string to indicate that any 'executable' file with the 'extension' of .mp3 is to be interpreted by /usr/bin/xmms, so the registration strings are
echo ":xmms:E::mp3::/usr/bin/xmms:" > /proc/sys/fs/binfmt_misc/register echo ":mps:E::mp3::/usr/bin/xmms:" >/proc/sys/fs/binfmt_misc/register echo ":ogg:E::ogg::/usr/bin/xmms:" >/proc/sys/fs/binfmt_misc/register echo ":m3u::E:m3u::/usr/bin/xmms:" >/proc/sys/fs/binfmt_misc/register
Now, when we (as a regular user)
~ $ chmod u+x my_life_changed.mp3
and then
~ $ my_life_changed.mp3
up pops XMMS and the music plays on.
The format and variations of the "registration" string are documented in /usr/src/linux/Documentation/binfmt_misc.txt.
Kewl, eh?
My thanks to Michael Heiming and Chris F. A. Johnson for pointing out
how to do this.
Two cent tip: ISO 8601 datesOn wondering if his tip was lost entirely. We don't always publish tips in the same month that we get them. -- Heather
No, they've always been sent to tag@...
[Heather] Strictly speaking, 2c tips began as good bits from people who weren't the Answer Guy. They tended to be, but weren't always, short, and were handled by the editor - I only did the TAG column. After some point I got involved with formatting tips as well, and then they were effectively merged with The Answer Guy's stuff, short items being put towards Two Cent Tips. With the advent of the Answer Gang, I actively encourage people wherever I run into them - send in your good tips
![]()
The confusion seems to have arisen from my header on the 2c tips column being too plain. sigh
Someone looking for the right submission address might (as I did) follow the link from http://linuxgazette.net to the Author FAQ, which says to mail article submissions to articles@linuxgazette.net and news items to bytes@linuxgazette.net. If we want the uninitiated to use the desired submission address for 2 cent tips without having to ask here first, it probably would be prudent to amend the Author FAQ, nicht wahr?
[Thomas] You might as well add it. No harm in doing so.
[Ben] It'll make it easier for authors who want to submit tips.
Anyway, this duplicates my June 18 post to "articles@linuxgazette.net":
One feature of the GNU coreutils' "date" program that's indispensible in
creating date-stamped filenames: "date --iso-8601" returns the current
date in international date standard (ISO 8601) format. E.g., on June
17, 2005, "date --iso-8601" returns "2005-06-17".
Why is this so handy, you ask? First of all, ISO 8601 dates sort correctly in ASCII- or alphabetical-ordered listings, unlike any number of other popular date formats such as 06/17/2005 (United States), 17-JUN-2005 (NATO), or the Commonwealth format I grew up using (17/06/2005).
Second, like NATO format, it's unambiguous to people everywhere, a virtue I would have appreciated when I switched from the British school system to the USA's (and thus, suddenly, all written dates before the thirteenth of each month were indeterminate).
I use the technique frequently when archiving file trees, as follows:
$ tar czf /tmp/etc-$(date --iso-8601).tar.gz /etc
It should be noted that ISO 8601's format has long been traditional in Chinese culture. It's always good to have a quarter of humanity on one's side for starters.
There are elaborations to the standard, that are somewhat less immediately applicable to computing, e.g., time of day would be written in the obvious 24-hour hh:mm:ss or hhmmss formats. One can append a "Z" suffix if such time-stamps are in zero-meridian ("Zulu", aka UTC) time. Otherwise, times are impliedly local.
Unfortunately, the International Organisation for Standardisation (ISO) do not have a freely downloadable copy of the ISO 8601 standard, but independent authors Gary Houston, Steve Adams, and Jukka Korpela have written pages that may be of interest to the more devoted calendar freaks (including code snippets for some common programming languages):
"Giga Unzipping"Unzipping large files on linux
Thanks to Thomas Stromberg for first describing this increasingly essential tool: p7zip
http://sourceforge.net/projects/p7zip
Many Microsoft users these days are using PKZip 4.50 to archive such things as VMware machines, and we need to be able to extract such archives on linux, which is where p7zip comes in:
p7zip can extract zip files which contain archived files larger than 4 gigabytes.
You'll know you need it if you see a "skipping:" warning containing the following message from the regular linux unzip:
need PK compat. v4.5 (can do v2.1)
The following is a WiKi page with a similar description, and some details on building p7zip and basic usage:
http://www.penlug.org/twiki/bin/view/Main/GigaUnzipping
[Jimmy] If you want to compress large files, you could also try out rzip, which is specifically designed for huge files.
a GTK based editorHi,
I am looking for a GTK based programme editor (for c/c++/perl/python/shell-script) which is fast as well as enriched with features. in my debian sarge there are a no. of different editors. I have found beaver, scite etc. which are based on GTK and demand having good features. as I have experience working with kate only so I really don't have any idea about these editors. could users of these editors kindly share their working experience so that I can pick one (fast+feature rich) among these ?
[Adam] I'm not familiar with sarge -- I run SuSE 9.x -- but I'm sure you must have Vim, which is my favorite, but demands some study, and Xemacs, which can basically be used like a GUI word-processor, except for a few commands. Does your system offer Nedit? It'a a great WYSIWIG type editor that can be used for programming like VIM or Emacs/XEmacs. I don't think any of these are GTK based, but why does that matter?
[Jimmy] You can have both with Gtk: both XEmacs and Emacs can be compiled with Gtk (IIRC, the Gtk interface is standard in the newest version of Gnu Emacs); Vim fans can use gvim.
[Raj] I personally use Emacs - but if you are looking for GTK based app - I can suggest Anjuta. For debugging, ddd presents a nice gui to gdb
thanks Raj, aptitude intends to install majority of GNOME package with anjuta (my window manager is icewm). that's why I have skipped anjuta and using scite.
Verifying CD'sHi, Jim:
Mind if I ask you a quick question? How can I verify that the .iso that I
burned to CD was written correctly? `md5sum /dev/cdrom` doesn't seem to be
working.
[JimD] I think you may be having "padding" problems. Read the following to understand what's happening and how to work around it with the isoinfo and dd commands:
http://www.troubleshooters.com/linux/coasterless.htm
Hope that helps.
I'm copying Heather on this and, with your permission, I'd like to have her include it in the 2-cent Tips column or Answer Guy in the next issue of the Linux Gazette (http://www.linuxgazette.net). (Your e-mail address, and optionally all other identifying info regarding you, would be stripped before publication).
Just for a quick hack I re-implemented the script that he used can called "rawread"
See attached isoread.sh.txt
... that can be published given that Steve Litt's copyright on the Troubleshooters.com website would not allow it to be copied freely.
Besides those one demonstrates a novel use of the eval command for exporting variable value pairs out of a command substitution sub-process back into our script (obviating the need to clobber our positional variables, run the isoinfo command twice, or fuss with nastier parsing of the isoinfo output).
There is, apparently, a readcd binary command that also comes with the CDR Tools package (which is where isoinfo comes from, at least on my Debian system).
Perhaps readcd does the same thing as this script. Perhaps it does it even better.
rxvt configuration for fontHi,
as rxvt is very fast and small I am using this. I have configured it like:
rxvt -cr green -pr red -bd red -name "This rxvt is modified by J.Bakshi" -sr -cursorColor2 red -scrollColor white -troughColor black
now rxvt has become very pleasant -
) but the font is very small and is very difficult to read. how can I set the font size and how can I get a different font ?
please let me know. thanks for your time.
[Thomas] By using the "-fn" option to rxvt, or adding:
rxvt*font: -foo-courier-foo-120-*-*-*
(use 'xlsfonts' for a proper font-string.)
to your ~/.Xdefaults or ~/.Xresources file (same difference), and running:
xrdb -merge ~/.Xdefaults
Or by just invoking rxvt, and pressing shift and "+" on your numeric keypad.
Or you could have read the man page for rxvt. Or seen the FAQ on it.
Hurray !!! now I have a rxvt with font style too. Thanks. I have come
to know about xlsfonts from this mail -
is there any tool which can
also show the preview of the font style ?
once again thanks for the solution
[Thomas] "xfontsel", "gtkfontsel", etc.
this one is not working in my machine
[Thomas] It does here. But it's also a configurable resource that rxvt responds to.
hello linux gurushi there, as i am much interested in setting up a squid proxy in my internet cafe (due to bandwidth cost)i do like to have some questions to be answered , here are those i cant able to solve. 1.did configured squid and allowed my client lan browsable via 3128 port but the thing is i can able to access webcam and voice mail !.i came to know that if u masquade the port 3128 to 8080 i can be achived but i cant able to write the rule , let me know how to write a firewall rule.
[Thomas] I assume you mean IPTables? You could try something like this:
# Allow forwarding. echo "1" > /proc/sys/net/ipv4/ip_forward # Forward from port 3128 -> 800 $IPTABLES -t nat -A PREROUTING -p tcp -i $INET_IFACE -d $INET_IP --dport 80 -j DNAT --to $DNAT_IP_PORT $IPTABLES -A FORWARD -p tcp -i $INET_IFACE -d $INET_IP --dport 3128 -j ACCEPT
You'd have to change things, of course.
2.even though i configured my proxy i cant save bandwith , i have a doubt that do my lan requests are cached by my porxy.how to check that ?, if no what i have to do ,let me know the key configuration in squid for that ?
[Thomas] There's a cache_mem_limit as well as different cache_* options that you can set. Have a look at /etc/squid/squid.conf -- it is the best commented config file I have ever seen and used.
OO Calc and VBAA question I've seen come up with some regularity in other Linux magazines goes a little like this: "is it possible to use my VB macros in OpenOffice", with the usual half-right answer: "No, Star Basic isn't quite the same as VBA" (correct) "but it's close enough that rewriting the macros should be easy" (not quite -- that's a bit like saying that Windows applications should be easy to port to KDE because both are written in C++).
The good news for would-be converts is that Novell are working on adding Excel
compatibility to OO Calc:
http://ooo.ximian.com/patches/vba
http://www.gnomebangalore.org/?q=node/view/873
There's also an XPCOM to UNO gateway, so Mozilla developers can use OOo and vice versa. -- Jimmy
|
...making Linux just a little more fun! |
The Answer Gang
![]() By Jim Dennis, Jason Creighton, Chris G, Karl-Heinz, and... (meet the Gang) ... the Editors of Linux Gazette... and You! |
We have guidelines for asking and answering questions. Linux questions only, please.
We make no guarantees about answers, but you can be anonymous on request.
See also: The Answer Gang's
Knowledge Base
and the LG
Search Engine
Greetings from Heather SternHello everyone, and welcome once more to the world of The Answer Gang. Sorry I don't have much to say this month - however, the Gang's said plenty, and I think you'll find it a good read.
For the second half of this month I'm going to be in the UK. Jim (the Answer Guy) is training the staff at one of his company offices there, and of course I am joing him. I've been told many wonderful things about England, its countryside, its brews - but not about the petrol and train ticket prices
-- it'll be an adventure.
Here's hoping you and yours are safe - good friends stick together. 'Til next month...
Not a simple NFS question (2.6.11.11)From Justin Piszcz
Answered By: Thomas Adam
I have a Debian Etch (testing) machine running 2.6.11.11.
Using FTP, I can easily achieve 10MB/s+ (megabytes per second) to or from the box. The main HDD in the box is a 400GB, 7200RPM, ATA/100 HDD attached to an ATA/133 Promise Controller.
I believe the problem began when I upgraded the box to 2.6.11.
Problem Description:
Sending files to the box via NFS is slow, 1MB/s for a few seconds, nothing, then 2-3MB/s then back to nothing.
Receiving or (pulling) files from the box achieves a sustained transfer rate of 10MB/s+ (megabytes per second).
Boxname = p4box.
p4box (share = /home/myfiles)
If I mount p4box onto another box:
# mount p4box:/home/myfiles /mnt # cp 1gbfile.txt /mnt
The above process will take forever, stall, lag and etc.
If I mount p4box onto another box:
# mount p4box:/home/myfiles /mnt # cp /mnt/1gbfile.txt .
I get normal NFS speeds on a 100mbps network.
The problem also occurs in the following scenario:
On p4box (box with the problem):
I:
# mount remote_machine:/disk2 /mnt # cp /mnt/1gig.txt .
This also does average 1MB/s, but not consistent, it peaks and goes slower and then nothing at all for a while.
If I do the same and copy something to the NFS share (outbound) then it runs at 10MB/s (megabytes per second).
The issue is inbound NFS is VERY slow.
On the affected box:
# Kernel Interface table Iface MTU Met RX-OK RX-ERR RX-DRP RX-OVR TX-OK TX-ERR TX-DRP TX-OVR Flg eth0 1500 0 1283895 0 0 0 636062 0 0 0 BMRU lo 16436 0 1040 0 0 0 1040 0 0 0 LRU
There is clearly no network issue.
REMEMBER: FTP works at full speed in both directions.
# rpcinfo -p l1
program vers proto port
100000 2 tcp 111 portmapper
100000 2 udp 111 portmapper
100021 1 udp 32768 nlockmgr
100021 3 udp 32768 nlockmgr
100021 4 udp 32768 nlockmgr
100024 1 udp 831 status
100024 1 tcp 834 status
100003 2 udp 2049 nfs
100003 3 udp 2049 nfs
100005 1 udp 996 mountd
100005 1 tcp 999 mountd
100005 2 udp 996 mountd
100005 2 tcp 999 mountd
100005 3 udp 996 mountd
100005 3 tcp 999 mountd
I've tried rebooting the box, disconnecting/remounting/etc, nothing seems to solve this issue.
I've searched Google and the Web but I have not found anything pertinent to this situation.
Does anyone have any idea what I can try next?
Thanks!
Justin.
[Thomas Adam] You haven't told us how you mount your NFS share -- i.e. what options you have contained in /etc/fstab. You can control the data rates with:
wsize= rsize=
which are values you can specify (usually in KiB) so that you don't throttle anything.
Pretty standard options:
l2:/d3 /l2/d3 nfs rw,hard,intr,nfsvers=3D3 0 0
These options are on three boxes, each with its own NFS share and I only have the problem on 1 machine.
The problem is solved.
The switch I was using went bad.
Optimizing Apache2 and MySQL installFrom Suramya Tomar
Answered By: Thomas Adam, Yan-Fa Li, Ramon van Alteren
Hi Everyone,
I have another problem and I was hoping that you will be able to help me solve this one too. I am hosting my website on a Debian Sarge system on a LVS (Linux Virtual Server) with 64 MB RAM and 64MB swap using Apache, PHP and MySQL. The problem I have is that every so often the Apache and MySQL process start taking 100% of the CPU and RAM and after a few mins of which the system runs out of RAM and the kernel starts killing processes (MySQL is usually the victim) which means my site goes down till I restart that process.
Is there some way I can optimize MySQL and Apache and tell it not to use so much RAM/CPU? I tried searching on the web but didn't find anything relevant. I am running Apache2, PHP 5, MySQL 4.1.10 on this box.
Apache was compiled with:
--enable-ssl --enable-cgi --with-ssl --enable-module=so
PHP With:
--with-bz2 --enable-ftp --with-gd --enable-exif --with-jpeg-dir --with-png-dir --with-ttf --with-freetype-dir --with-imap=/usr/local/imap --with-mcrypt --with-mysql=/usr/local/mysql/ --with-openssl --with-cpdflib --enable-soap --with-zlib --with-apxs2=/usr/local/apache2/bin/apxs
and MySQL with:
--with-mysqld-user=mysqld --with-openssl
The website gets about a 1000 - 2000 hits a day and I have 2 blogs(Using Serendipity Ver 0.8.1) running on this system. I also run Sendmail on the box but is only used locally to send mails from Serendipity and my guestbook. I don't allow any external connections to port 25.
The error I see in the /var/log/messages when a process is killed is:
Jun 21 13:44:21 wyrm kernel: __alloc_pages: 0-order allocation failed (gfp=0x1d2/0)
Output of free:
wyrm:/home/suramya# free
total used free shared buffers cached
Mem: 60500 59092 1408 0 660 27324
-/+ buffers/cache: 31108 29392
Swap: 65528 28648 36880
Output of top right now:
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 740 apache 14 0 13400 9908 2992 R 57.8 16.4 0:28.18 httpd 809 mysql 20 0 11676 2416 2204 R 35.5 4.0 0:01.20 mysqld 459 mysql 9 0 11676 2416 2204 S 1.9 4.0 0:04.74 mysqld 808 root 9 0 1044 1044 852 R 1.3 1.7 0:00.09 top 4 root 9 0 0 0 0 S 0.3 0.0 0:22.18 kswapd 798 apache 9 0 6928 3660 3056 S 0.3 6.0 0:06.91 httpd 1 root 9 0 100 72 72 S 0.0 0.1 0:00.21 init 2 root 9 0 0 0 0 S 0.0 0.0 0:00.00 keventd 3 root 19 19 0 0 0 S 0.0 0.0 0:00.00 ksoftirqd_CPU0 5 root 9 0 0 0 0 S 0.0 0.0 0:00.00 bdflush 6 root 9 0 0 0 0 S 0.0 0.0 0:00.00 kupdated 7 root 9 0 0 0 0 S 0.0 0.0 0:00.00 jfsIO 8 root 9 0 0 0 0 S 0.0 0.0 0:00.00 jfsCommit 9 root 9 0 0 0 0 S 0.0 0.0 0:00.00 jfsSync 10 root 9 0 0 0 0 S 0.0 0.0 0:00.00 xfsbufd 11 root 9 0 0 0 0 S 0.0 0.0 0:00.00 xfslogd/0
Any suggestions on how to reduce the load and prevent the system from dying every few hours?
[Thomas] Well, there is. If it is really a problem, you could compile your own kernel, and not compiling the OOM-killer into it. That would stop the kernel's divine intervention, at any rate.
More practical purposes though would be to limit the amount of RAM that the processes can use. Recent versions of PAM allow for this through the file: /etc/security/limits.conf For example, on Debian, Apache runs via the user 'www-data'. In that file, you could add an entry thus:
www-data soft cpu 6000 www-data hard memlock 700000
The difference between hard and soft is almost analogous to how quota enforces them -- soft is a graceful enforce, while hard is a complete cut-off. The values above are examples only -- you should change them to suit your needs, at any rate.
The use of limits.conf via PAM is really much more applicable to daemon-based tools, although it can be applicable to anything. It used to be the case that you'd have to do:
ulimit -l <some_value>
.. and you still can. It's great to do that for login shells, etc. The problem with that is for daemon processes that do not spawn a shell when the process starts, makes it invalid. Not to mention the user that the daemon runs at doesn't have a shell.
You can apply a similar methodology for MySQL.
[Yan] Just an observation, stop being so miserly with your RAM. 64MB is very little ram for a DB and a web server and your scripts,
[Thomas] Really? I refute that, given the tools available to limit things. I have 64MB on a P166 which runs: Exim, Squid, Apache, MySqL, Ruby-on-Rails. It has no problems whatsoever. 64MB is not miserly at all -- and there's nothing to say one needs $MASSIVE_RAM for applications to run -- if you believe that, you'll believe anything.
[Yan] Really, interesting and you're right. But this isn't an embedded system we're talking about, it's a linux VLS, which is running on a real Linux box, so he must have access to more resources causes he's already paying the overhead of VLS and it's already thrashing the CPU so it's stealing cycles from the rest of the system because it's thrashing.
Its an LVS being run by a hosting company. If I want to increase the
available RAM I have to pay extra and thats something I want to avoid
till I have exausted all other options. Its not that much more expensive
but why pay more when some small config changes will fix the problems,
right? :)
[Yan] MySQL 4.1 is the latest greatest and it's a bit of pig, usually eats up 16-32mb. What are you running 3.23 ? That's miserly in comparison. Squid in non caching mode is pretty small agreed, but then it's only a proxy. Apache 1 or 2, Apache 2 takes up more room, just did a quick check on my system and it's resident at Virtual 20MB, resident at 9MB. What version of Linux 2.2 or 2.4 ? 2.4 is comfortable at low memory, 2.6 is less so.
I am running MySQL 4.1 on Linux 2.4.
[Yan] What does your my.cnf look like, I think that would be useful for the person who posted.
I just look at MySQL 4.0.20 and it's 30MB virtual and 10MB resident with default settings, i.e. an empty my.cnf.
I am using the default settings for mysql, if you have a config setting
that is more lightweight then I am willing to try it out.
[Yan] And I'm not talking $MASSIVE_RAM. I'm talking 96MB. By todays standards that's nothing. This is 2005, a barebones system is 1GHz with 256MB of RAM. A P166 was state of the art 10 years ago, though I'm glad to see you're recycling it.
:) I have spare machines at home but don't have the bandwidth to support
my site so I have to stick with this server until I can either convince
my boss to let me host my site on an office server or convince my wallet
to pay for a bandwidth upgrade at home.
[Yan] increase your LVS to 96MB and re-test. The other thing to do is try and run the MySQL database on another machine/virtual server over the network.
[Thomas] Which would be very slow indeed.
[Yan] MySQL is NOT slow over the network, that's a complete myth. It's not as fast as running it over a Unix socket, but it's not slow by any means, especially compared to the slow down of a P166
Try doing a benchmark between your P166 running mysql and a faster machine over the network running MySQL. Any query of decent complexity will still run faster on the network machine. Plus if his VLS is crashing all the time he'll spend more time running myisamchk on it than he would just moving it to a stable box.
I was considering hosting the DB on my home machine but thats connected
to the net using a cable modem so I don't know how feasible that would
be. Will try out some tests and see how that looks.
The site wasn't doing too bad till 2 days ago then suddenly for some reason the processes started dying every few hours. Maybe my traffic shot up or the blog software went nuts.
[Yan] He also stated he's running an app he didn't write, a blog. So who knows what's it's doing with memory or SQL queries. Perhaps it has some configuration knobs that can be used to minimize it's footprint.
Yeah, I think the blog is the biggest resource consumer. Anyone know a
more lightweight blog thats not horibly ugly looking?
I have put in the changes Thomas suggested on the system and so far it seems to be stable. I am waiting till tomorrow and see how it works out overnight but so far that one change seems to be working great.
[Thomas] I assume you've just joined, Yan-Fa Li? Welcome, if so. Perhaps you'd oblige is by NOT top-posting? Thanks.
[Yan] Sorry for top posting, my bad.
[Yan] You can edit the /etc/my.cnf and cut it to the bone, but you're really trading RAM for performance. The less RAM, the lower your performance. Go to mysql.com and look at the variables you can set and set them to the bare minimum.
Also, configure apache to not load so many modules. You can control that from your httpd.conf. But honestly, the amount of effort to get this to work vs just adding more RAM or swap, I'd say it isn't worth it.
Just my 0.02c
[Ramon] Have you taken a look at wordpress ( http://www.wordpress.org ) ?
It's a 300k download, looks nice (subject to personal opinion) and isn't as resource-hungry as serendipity. If you don't like the default look it has extensive theming features and css support.
"Tips if you've got some"From Lew Pitcher
Answered By: Ben Okopnik, Thomas Adam, Karl-Heinz Herrmann, Rick Moen
OK, Here's a quick one for you.
I mostly use Blackbox as my window manager, and it doesn't come with a lot of tools. Often, I need to view a calendar, and since there's no native calendar function for Blackbox, I quickly invented one.
It consists of two parts:
Part 1 is a script that I call ~/bin/Xcal. It displays the results from cal(1) in an xmessage window, and has buttons to move forward and backward through the yearly calendar, and a button to quit the calendar completely.
This script looks like...
[exec] (Calendar) {~/bin/Xcal }
And that's it. One click brings up the calendar for the current year. I can move backwards and forwards in it, a year at a time, and dismiss it when I'm done. A simple, straight forward, lightweight solution to my desk calendar requirements.
[Ben] Very nice, Lew!
Thanks. It's a bit rough around the edges, but it works :-)
[Ben] I've just tried it out, and it's quite the nifty gadget. [runs with scissors]
Carefull with those sharp objects. You could cut(1) yourself, and that would
hurt.
[Ben]
if [ $I = "do" ]; then I=`ll make -sure to | paste -a BandAid | over -it`
[Ben] I'm sure that I'll be tweaking it in various ways,
Please be my guest. Tweaking is what we do, isn't it?
[Ben] Well, yeah. :)
See attached Xcal-ben.sh.txt
One comment/question
In blackbox, the window controls (i.e. "kill client" or the "x" close button) won't terminate the script. That's because the exit status isn't one of the three in the list.
So, try this tweak...
See attached Xcal-lew2.sh.txt
[Ben] Seems like just changing 'Quit' to '*' should do it - since any option other than 'Next' or 'Prev' should exit.
Yes. I thought of that. The only reason I coded it the way I did was for the
convenience of the next 'tweaker'.
If I dropped the "Quit" regex from the case statement, it wouldn't be clear as to how the xmessage Quit option is handled. OTOH, adding a match all ('*') regex gives the next tweaker the clue that there are conditions other than 'Quit' that can (or should) cause the script to exit.
In any case, the next tweaker might decide that the exit status from a WM cancel should be different than the exit status from a 'Quit' button press, and recode the case statement to something like...
See attached Xcal-ben2.sh.txt
[Ben] Note that with the '-default Quit' option, even hitting 'Enter' while Xcal has the focus will cause it to exit.
True, but I didn't try that :-)
I tried clicking the WM 'kill client' decoration instead, and the script didn't exit.
Never overestimate the end user's capabilities. I've learned that in my other life (an 'IT Specialist' for a large Canadian bank, and a specialist in banking application programming). ;-)
[Ben] but the basic functionality is just super all by itself.
Thanks!
You're welcome. I've got lots from you guys, and I'm more than happy to give
back.
[Ben] [grin] That's my take on what I do, too. It's one of those good feedback loops - creates good synergy.
[Jimmy]
Since you've mentioned calendars, does anyone know of any calendar programs
that can deal with recurring events without having to use ical?
My work schedule looks like this:
(Beginning June 6th on week 1 (i.e. I'm on Week 4 now), where the hours are
7.20 [AP]M to 7:50 [PA]M, except for one day)
Fri Sat Sun Mon Tue Wed Thu Week 1 PM PM PM AM AM Week 2 PM PM PM PM Week 3 Week 4 4pm AM AM AM AM
Is there anything around that can take a simple, text input and show what hours I'm working on a given date? The ical-based calendars mostly work, but most don't really handle overnight events and those that do take too bloody long to set up.
[Thomas] There's the motif-based application: "plan".
[Jimmy]
Damn. I meant to say 'console-based'. I might give it a look, even if it
does need such an obscure library :)
[Karl-Heinz] plan has a commandline interface for a quick check of appointments and I think even setting.... yes: manpage has plenty of commandline options. Give it a go, but the "gui" is motif based. The whole is in three parts, the plan program, a deamon doing the "alarms" and a notifier popping up the alarm windows. It can also send mail.
[Rick] Compiles with lesstif, too. (Ugly as sin, either way.)
I used to use the clunky old thing at a prior firm. Frankly, I much preferred my PalmPilot.
[Ben] A while ago, I saw a CGI prog that was intended to demonstrate the Palm - and did a pretty darned good job of it, if I recall correctly (it's one of the things that helped me make up my mind about buying one, back when.) Let's see if I can still Google well...
Ah, there it is: Palm-FE
Enjoy.
[Jimmy]
Looks cool. Haven't tried it out yet, but calendaring is on the TODO
Fsck woesFrom James Scott-Brown
Answered By: Thomas Adam, Sindi Keesan, Heather Stern
Recently, My GNU/Linux system (Fedora Core 3) was shut down uncleanly. It booted to single-user mode and told me to run fsck manually, which I did. After asking whether it should correct a number of error (to which I replied 'y'), it reported that the file system was altered and the system should be rebooted. So, I entered the 'exit' command and the system rebooted.
When it rebooted, the system again reported the system had shut down uncleanly. It ran fsck again, and it produced the same error messages. It fixed these, and I rebooted. This happened again . and again . and again.. more than 5 times. I booted off a live CD (KNOPPIX) and verified that all the system files were actually there - they were. What should I do?
[Thomas] Yup, this sometimes happen. I'd boot off the knoppix CD, chroot over to your FC installation and use "tune2fs":
tune2fs -c 100 -C 1
[Sindi] I had a crash with Slackware one time and was able eventually to get it booting by reading the manual for e2fsck and typing
e2fsck -b 16385 -n /dev/hdb2
(linux is on hdb2, not mounted)
-b means use alternate superblocks because the regular one got messed up during the crash. Linux keeps extra copies.
16385 is one of my alternate superblocks. When you first run mke2fs it gives you a list of about five of them spread out over the partition. My partition was 1 or 2G. Larger partitions have them in different places and you can probably look up likely superblocks on the web and try this approach.
-n means answer no to all questions, or you can do that manually
superblocks seem to be multiples of a base number plus 1: 8193 16385 (and probably 3 and 4x 8192 + 1, etc.)
Maybe someone else with your size drive can suggest where they are.
I have e2fsck on a 2-floppy linux for this sort of use.
[Heather] According to the man page for mke2fs, you could ask it where it put them:
-n causes mke2fs to not actually create a filesystem, but display
what it would do if it were to create a filesystem. This can
be used to determine the location of the backup superblocks for
a particular filesystem, so long as the mke2fs parameters that
were passed when the filesystem was originally created are used
again. (With the -n option added, of course!)
Sound disappearing with KDE upgradeFrom Mike Orr
Answered By: Jimmy O'Regan, Karl-Heinz Herrmann, Ben Okopnik
I upgraded to KDE 3.4 from 3.3 and went through a ritual that's unfortunately too familiar: figuring out why my sound disappeared.
The first indication was an error message from my CD player: "Unable to open cdrom device /dev/cdrom".
$ ls -l /dev/cdrom lrwxrwxrwx 1 root root 3 Aug 15 06:00 /dev/cdrom -> hdc $ ls -l /dev/hdc brw-rw---- 1 root audio 22, 0 Jul 15 2004 /dev/hdc $ groups wheel floppy audio cdrom dialout cdrw users portage rex $ su -c 'chgrp audio /dev/hdc' Password: $ ls -l /dev/hdc brw-rw---- 1 root audio 22, 0 Jul 15 2004 /dev/hdc
Now my CD program would start but was silent. There was a slash over the speaker icon in the system tray. Having had problems with mute before, I clicked that to open KMix. There were more items under the 'Output' and 'Input' tabs than previously, and I quickly saw the "Output: Master" and "Input: CD", but where was the output for /dev/dsp, and is that the same thing as "Output: PCM"? I knew the buttons above or below the sliders were 'mute', but which position is muted? I fiddled around to what I thought was right but not a peep from the computer, so I put on a record instead and went to sleep.
As always, things seem clearer after a good sleep. I checked the permissions of /dev/dsp, which was symlinked to /dev/sound/dsp. It already had write permission for group 'audio', of which I was a member, so I went hunting further. The speaker still had a slash, so I single-clicked it and saw a 'Mute' item, which was checked. I unchecked it and the 'Ouput: Master' button in KMix went from dark to light. Aha, that's the unmuted position.
I tried playing a CD again but the permission problem had returned. I chgrp'd it and looked through the logs for some message about what it's doing now, or what it had been doing before the upgrade that it isn't doing now, but nothing.
I picked a show on the To The Point (http://kcrw.org/show/tp) webpage (RealAudio) and it played OK. (The main thing I listen to is time-shifted NPR programs. TiVo for radio, I guess. It's frustrating when you wake up late Saturday morning and can't listen to Weekend Edition or Car Talk (http://www.cartalk.com). Then you remember, "Oh yeah, people used to have to listen to programs when they were broadcast....")
Anyway, back to the silent CD player. Its volume control and 'mute' button did nothing, so I perused KMix again. 'Input: CD' had the green and red buttons both dark, so I clicked the green button and Badorb's "'Ow Much?" played on top of top of Warren Olney. (The show was called "Googled! Will the Internet Come Back to Haunt You?", about how Google's CEO didn't like having his personal information published after a reporter, er, googled it. Oops.")
So everything is resolved now except the wandering groupness of /dev/hdc. Since it's Gentoo I'll have to check whether devfs is operating and whether it's restoring permissions from a tarball. Hmm, what all did KDE upgrade with itself? /var/log/emerge.log shows arts, pam, kdebasepam, gstreamer, gst* as potential culprits. And cdparanoia. Probably not, but I like the thought of blaming things on cdparanoia. (To make emerge.log more readable I wrote a Python program that converts tick dates to ISO format.)
See attached format_emerge_log.py.txt
Well. everything is resolved except that TkMan's font is unreadable. So much for "New Century Schoolbook". I tried "Helvetica - medium - normal" and the results look, well, vaguely like Hebrew.
See attached tkman.png
Well, and the fact that Konqueror lost my bookmarks. Not only that, they reverted to a configuration not seen since before my Firefox import. That was easily fixed with "Bookmarks -> Edit Bookmarks -> File -> Import -> Import Mozilla Bookmarks".
Anyone know how to tame Firefox into playing this sound link? http://www.npr.org/templates/story/story.php?storyId=4800040 ("No Static at All: Hi-Tech Radio") It's got some Javascript function to choose the file that seems to be too much for Firefox.
[Jimmy] Whenever I came across a site like that, I normally tried to pick apart the javascript to find the actual URL, and just grabbed that.
Yes. It's finding and deciphering the Javascript function that stumped me.
[Jimmy] Oh. It's in http://www.npr.org/include/javascript/jsfuncs.js
It's called with "javascript:getMedia('ME', '15-Aug-2005', '8', 'RM,WM');", so assuming you want the Real Media version, the URL should be:
http://www.npr.org/dmg/dmg.php?prgCode=ME&showDate=15-Aug-2005&segNum=8&mediaPref=RM
[Jimmy] I used to have a few shell functions for different sites that amounted to "wget http://some.site/foo/bar?baz=$1"
[Karl-Heinz] I'm regularly recording radio shows, musik programs etc. from two German stations which also broadcast mp3. I'm also using wget, but wanted it to record a specified time and then terminate. Also I had to check if the wget actually is running, because for weekly crime radio show (I still don't know a good translation for Hrspiel, like a book reading but with different actors) the first trys to get a connection sometimes failed.
It's probably still quite clumsy, but it the best way I found to get the pid of the wget from the starting script. I usually run it with at and get an E-mail with the messages.
See attached radiograb.sh.txt
[Ben] Just FYI: the PID of the last backgrounded process you've launched is contained in "$!" - at least under any "sh"-derived shell.
ben@Fenrir:~$ date & echo $! Sat Aug 27 14:54:05 EDT 2005 [1] 6152 6152 [1] Done date ben@Fenrir:~$
Any synchronous processes launched after that don't affect the value in "$!"; it has to be an asynch process.
ben@Fenrir:~$ date; echo $! Sat Aug 27 14:55:57 EDT 2005 6152 ben@Fenrir:~$
I'm thinking about making a cron job that pulls the web pages of my
half-dozen favorite radio shows and makes a menu of the latest ones, so I
can just choose an interesting-sounding title and play it. Some of the
sites have RSS feeds, so that'll make it easier.
[Jimmy] Sometimes you need to set a referer, sometimes you need to masquerade as another browser, but it's quicker than browsing most of those sites.
On a good note, Firefox can now play the BBC's embedded radio player.
http://www.bbc.co.uk/radio/aod/mainframe.shtml?http://www.bbc.co.uk/radio/aod/index.shtml
[Jimmy] I used to use MPlayer's 'dumpstream' option to listen to the book readings on BBC4 (usually whenever they had pTerry readings) because streaming audio annoys the crap out of me.
Python vs. PerlFrom Benjamin A. Okopnik
Answered By: Mike Orr, Jim Dennis, Rick Moen, Jimmy O'Regan
Have I mentioned, yet, that I DON'T KNOW PYTHON? Just in case I haven't, I DON'T KNOW PYTHON. Since I DON'T KNOW PYTHON, my tweaking is guided by something other than knowledge; it can be approximately imagined as a cross between voodoo, poking a long stick down a deep hole which has ominous sounds issuing from it, and using a large axe to flail wildly in random directions. The only definite part of the process is that is takes a long time.
[Sluggo] You mean you don't find it immediately more readable than Perl? Nice English words instead of obscure symbols, less packing of several operations in one statement?
[snort]
files = ["lg/" + x for x in files if x]
This is supposed to somehow be less packed than a Perl statement?
[JimD] No it's not. However, it's no more inscrutable than a Perl statement either. Personally I unroll such "list comprehensions" when I know that non-Pythonistas are likely to read it:
results = list() # same as files = []
for x in files:
if x:
files.append("lg/" + x)
files = results
But the list comprehension syntax is still much cleaner than the horrid:
files = map(lambda x: "lg/" + x, filter(None, files))
which is the only one-liner I can think of to implement this prior to their introduction.
The closest I can come up with in Perl at the moment is:
@files = map { "lg/" . $_ if $_} grep(/./,@files);
... which took me an unfortunately long time (much to Heather's displeasure as I'm supposed to be taking her to a social event right now). I don't use perl often enough; so, the silly @this and $that get rusty and I didn't remember Perl grep().
Is there a good Perl to Python "Rosetta stone" out there that would have helped me find Perl grep() vs. Python filter() correspondence?
Yep - Tom Christiansen's "Python to Perl Conversions" list, which I ran
across quite a while ago. Unfortunately, the original link at
mail.python.org seems to be dead - but Google still has it cached.
[Rick] For what it's worth, I've saved Tom Christiansen's comparison chart for posterity:
"Python to Perl Conversions" on http://linuxmafia.com/kb/Devtools
[Sluggo] At least it doesn't have a regular expression embedded in it, or worse, a grep statement used to calculate something rather than to extract the matching lines.
So... "if x" is somehow better than "if /x/"? The distinction eludes me.
As to "grep", I think you mean "map" - which I understand Python also
supports.
[Sluggo] No, I mean 'grep'. Jim posted a perfect example.
Erm... your judgement of perfection falls a bit short of, well,
perfection.
In the example that Jim gave, that 'grep' is completely
superfluous. However, if you wanted to use it for something like this,
you could certainly twist it to the purpose:
@files = grep s{.+}{lg/$&}, @files;
However, just because you can doesn't mean that you should. From "perldoc -f grep":
|
...............
............... |
Using 'map' for its intended purpose seems to me to be much clearer, as well as avoiding that variable repetition:
map $_="lg/$_" if /./, @files;
[JimD] Not to defend my example but I'll point out that a) it worked for my test case (the side effect was irrelevant here but I can see where it would BITE someone somewhere else! and b) it looked reasonable to the one perl hacker I happened to show it to over a beer later that after- noon (at the social gathering which constrained my time on this little matter before).
Oh, I wasn't saying that it wouldn't work - just that holding it up as
an example of perfection and orthodox usage wasn't appropriate. It would
work just fine, though.
[JimD] To me it looks unnatural to use an assignment as the function in the map; but had I known it was legal than I might have tried this.
That's one of those things that makes 'map' so powerful and so complex:
it can be used to modify the array being processed, or it can be used to
return the result - which means that you can use it "on the fly" to
process your data so that it can be seamlessly plugged into the rest of
the procedure.
# Voting: multiple offices, multiple candidates
my %offices = (
Janitor => [ "Arnold", "Archie", "Anna", ],
Peon => [ "Barney", "Betty", "Basil", ],
Manager => [ "Carl", "Cyril", "Cindy", ],
CEO => [ "Dave", "Dana", "Darlene", ]
);
print header, start_html, start_form,
map table(
Tr(
td( "Office: $_" ),
td( radio_group( -name => $_, -values => $offices{ $_ } ) )
)
), sort keys %offices;
print br, submit( "Done" ), end_form;
Since 'map' and 'grep' both are implicit loops that allow acess to the underlying variable, it's easy to get in trouble when using them... but that's always the case with power tools: if they can cut through an inch of steel, they can certainly take off a finger. Safety guards (a.k.a. "documentation") are there for a reason. :)
[JimD] Oddly enough there was a case today where I had to think about Python's syntax for a minute before I could do what I wanted.
I was reading the new "Best Practices in Perl" O'Reilly book and came across the "Schwartzian Transform" example. This is known as the "DSU pattern" to Pytonistas (decorate, sort, undecorate).
Nicely descriptive, that. You might also want to take a look at
the GRT (Guttman-Rosler Transform), which is related but different (a
lot faster, for one):
#!/usr/bin/perl -w
my @words = <>; # Slurp the file contents
my @sorted = map { substr($_, 4) }
sort
map { pack( "LA*", tr/eE/eE/, $_ ) } @words;
print "@sorted";
}
[JimD] Their putative example was one of returning a list sorted by SHA-1 hashes of the element values.
I decided to write two versions of the example in Python: one that modifies the list in place and the other which returns a copy.
Returning the copy is easy and comes naturally:
from sha import sha
def sha_sorted(seq):
seq = [ (sha(x).hexdigest(), x) for x in seq ]
seq.sort()
seq = [ y for (x,y) in seq ]
return seq
(Actually I could sort by decimal or hex representations of the hash)
As you can see the first line decorates the list (by creating a list of tuples such that each tuple contains the hash, then the original item). The call to this list's .sort() method is all we need to do the right thing; since the Python .sort() methods are automagically multi-key when dealing with sequence objects like lists and tuples. Then we "undecorate."
That's easy. It's a little trickier to make it modify the object which was passed to it. In Python the seq = [ ... ] is binding a newly created list to the name seq. The object just happens to have been generated from the old object which was, co-incidentally, bound to that name prior to the new binding. We were passed an object reference, so how to me modify the object of that reference rather than creating a new object reference?
Here's the answer:
def sort_by_sha(seq):
seq[0:] = [ (sha(x).hexdigest(), x) for x in seq ]
seq.sort()
seq[0:] = [ y for (x,y) in seq ]
return None
... we assign a list of results to a slice of the list to which the name referred. It just so happens that we're replacing a slice that includes all of the items; and it doesn't matter if the new slice has more or fewer elements than the original list.
Of course that only works with mutable objects (like lists) so we can't write a function that modifies a normal Python string (which is immutable). We can write a function that returns a modified copy of a string, but we can't modify the string as a side effect of calling a function. In general we have to work to make any function modify something as a side-effect. (Of course our methods can modify their objects all they like ... but immutable members would simply be rebound to new objects with the desired transformations).
In general the Python community would use the first form, so the intended effect (changing "seq") was visible from the calling code:
seq = sha_sorted(seq)
rather than having this side effect:
seq = 'this is a test'.split()
sort_by_sha(seq)
# ...
[JimD] Overall I just prefer to have less punctuation and more text; easier for me to read and type.
[Sluggo] This also demonstrates another peeve: the magic variable $_.
[shrug] Peeve for you, immensely valuable for huge numbers of
programmers worldwide.
[Sluggo] 'map' can hardly be counted against Perl since Python also has it.
Yes, but Perl had it long before Python even existed.
[Sluggo] List interpolation like the above was a pretty unusual step for Python, but it turned out to be immensely popular.
Yeah, anything you steal from Perl is likely to be. :)
[Sluggo] 2.4 added generator interpolation (trade the [] for () and you get an iterator, which uses less memory if you only need the sequence once). We almost got dict interpolation until it was pointed out that you can make dicts like this:
pairs = [(key1, value1), (key2, value2)]
d = dict(pair for pair in pairs)
I just wish they'd borrowed Perl's ternary operator (?:). That was shot down coz there were some six different syntaxes with equal support proceeding.
[nod] I'm surprised that Guido didn't repeat Larry's method - i.e., just
put his foot down and say "it shall be so." The tendency for people to
wank endlessly with trivia is well known in those circles, and even an
arbitrary decision at those times is better than none.
[Sluggo] Actually, he did. Guido is not in favor of a ternary operator; he prefers an if-stanza. But it's been requested so persistently over the years -- moreso than any other construct -- so he wrote up a proposal and gave the community one chance to agree on a syntax. http://python.org/peps/pep-0308.html
|
............... Following the discussion, a vote was held. While there was an overall interest in having some form of if-then-else expressions, no one format was able to draw majority support. Accordingly, the PEP was rejected due to the lack of an overwhelming majority for change. Also, a Python design principle has been to prefer the status quo whenever there are doubts about which path to take. ............... |
You can already do:
result = condition and true_value or false_value
Sure - you should be able to do that in pretty much anything that
supports logical operators.
# Perl print 3 > 2 && "true" || "false" # Bash [ 3 -gt 2 ] && echo "true" || echo "false"
etc.
[Sluggo] but it produces the wrong result if true_value is empty (meaning zero, empty string, list/dict without elements, None, False). So you have to make sure true_value can never be empty. The ternary operator would eliminate the need for this paranoia.
[Nod]
[Jimmy] So... on the topic of 'map', how would I use a regex with the map in this:
sub am_asz
{
my $verb = shift;
my @end = qw (am asz a amy acie aj$a);
return qw (dam dasz da damy dacie dadz$a) if ($verb eq "da$c");
return qw (mam masz ma mamy macie maj$a) if ($verb eq "mie$c");
return "error" if (substr ($verb, -2) ne "a$c");
return map {substr ($verb, 0, -2).$_} @end;
};
> return qw (dam dasz da damy dacie dadz$a) if ($verb eq "da$c"); > ^^
That's not going to work - "qw" disables variable interpretation.
[Jimmy] Ah. Well, to answer your later question, those are the extra non-ascii characters in Polish. I just changed them here because I didn't want to mess around with character sets in my mailer, but in the actual version I use the real characters.
(I've chosen to return an array of possibilities in the event that the caller hasn't given enough information. I'm trying to find a way to sort by likelihood, but that may be a pipe dream).
What, weighted sorting? Pshaw. Pshaw, I say (perhaps because nobody
alive today pays even the slightest attention to a silly word like
"pshaw". I suspect he was bshaw's younger brother, the one that was
always picked last for the soccer team and such... But I Digress.)
#!/usr/bin/perl -w
# Created by Ben Okopnik on Thu Aug 18 01:11:46 EDT 2005
# I actually had to go look this up in a *book*. Jimmy, I'll never
# forgive you. :)
#
# Modified from algorithm shown in "Mastering Algorithms with Perl"
# (Jon Orwant, Jarkko Hietaniemi, and John Macdonald)
sub weighted {
my( $dist, $key_order, $total_weight ) = @_;
my $running_weight;
$key_order = [ sort { $dist->{$a} <=> $dist->{$b} } keys %$dist ]
unless $key_order;
unless ( $total_weight ) {
for (@$key_order) { $total_weight += $dist->{$_} }
}
# Get a random value
my $rand = rand( $total_weight );
# Use it to determine a key
while( my( $key, $weight ) = ( each %$dist ) ) {
return $key if ($running_weight += $weight) >= $rand;
}
}
%choices = ( eenie => 1, meenie => 10, mynie => 1, moe => 1 );
print weighted( \%choices ), "\n" for 1 .. 25;
[Jimmy] ...but if you had to look it up, maybe I was underestimating the 'how' part :)
Heh. That's more of an indicator of what I usually do or don't do with
Perl; I'd seen this thing before, and had actually reconstructed ~80% of
it from my memory of the underlying algorithm - but since the other 20%
wasn't instantly forthcoming, I said "HUMPH!" very loudly and went to my
bookshelf.
"MAwP" is a book of Extreme Coolness, anyway - it was a
pleasure to revisit.
Note the flexibility of the above: the key order and the total weight
can be supplied in the invocation - or they'll be computed using the
standard assumptions.
Loading the values for each verb from a *DBM hash or a MySQL DB is left to the individual student. :)
[Jimmy] My son found your choice of choices highly amusing :)
Oh, if I'd only known! I was going to make it a bunch of