Wikipedia:Reference desk/Archives/Computing/2011 May 28

From Wikipedia, the free encyclopedia
Jump to: navigation, search
Computing desk
< May 27 << Apr | May | Jun >> May 29 >
Welcome to the Wikipedia Computing Reference Desk Archives
The page you are currently viewing is an archive page. While you can leave answers for any questions shown below, please ask new questions on one of the current reference desk pages.

May 28[edit]

Single bad disk sector on a HD[edit]

I have a relatively new laptop harddrive that has what looks like a single bad sector (8 x 512 blocks = 4KB, which coincidentally lies on a sector boundary (divisible by 32) and our article mentions is the modern size of a sector). This particular sector's unable to be read or written to, and that includes using low level OS utilities like dd (unix). It lies inside an NTFS formatted partition. I tried to use the Windows 7 disk check utility to repair it, but it would, I think, randomly restart when it hit that sector. The process takes quite a while too so it's not something I could test all the possibilities for easily.

My question is, shouldn't the checkdisk utility mark the file in NTFS' bad block list, and move on? (data recovery is not an issue here)

Second, I've tried writing to this sector a number of times with low level utilities. Isn't this all it should take for the drive to reallocate the sector? That hasn't seemed to prompt that. I ran some SMART utilities on it (smartctl) and if testing the particular region it did find the errors, but still no reallocation.

Any insight on this issue would be helpful. Thanks. Shadowjams (talk) 01:37, 28 May 2011 (UTC)

I don't have any experience with Windows 7, but in earlier Windows versions I would do a ScanDisk, and not just the "surface scan" but the more detailed one. This typically fixed the problem, for a while. However, I also found that once one sector goes bad, more are soon to follow, so you need to consider getting a replacement. StuRat (talk) 06:51, 28 May 2011 (UTC)
(ec) Some (not all) current hard drives have 4KB sectors. More importantly, though, modern hard drives should not have any bad sectors that are visible to dd or the NTFS driver or any other ordinary software. Bad sectors (of which there are always many, on modern drives) are supposed to be detected and transparently remapped by the drive firmware. The block device that dd sees is pretty high level these days.
If the drive is under warranty, I'd call tech support; they will probably suggest you download and run a diagnostic utility provided by the manufacturer. If it's not under warranty, the diagnostic utility may tell you if this is a sign of impending doom or a fluke, and in the latter case, the manufacturer's low-level format utility will erase all data on the drive and probably eliminate the bad sector. If you don't want to wipe the drive, NTFS does support bad block management, but I don't know how it works since I've never had a bad block on an NTFS drive. You could try chkdsk /B, if you haven't already. -- BenRG (talk) 06:59, 28 May 2011 (UTC)

External Hardrive not Recognized by Vista[edit]


I have recently acquired an external HDD (1 TB). Everything was all lovely-jubbly until I used UNetBootIn to install Ubuntu 11.04 on a 100GB partition I had placed on the HDD. Now, it is not recognized at all by Vista. The entire HDD. What should I do to make it recognize the drive, and, can I get my data back..... ? --KägeTorä - (影虎) (TALK) 01:25, 28 May 2011 (UTC)

You are asking about losing access to the pre-existing partition from before you created the Ubunto partition ? What kind was it ? Was it bootable ?StuRat (talk) 04:43, 28 May 2011 (UTC)

'Pre-existing partition before I created the Ubuntu partition'? No, there wasn't one. It's an external HDD, and I created a 100GB partition on that drive. Before doing this, I was able to access the drive from Windows (via a USB cable), but now, the drive does not even show up - all of it, and not just the Ubuntu partition, which I expected not to show up, because Ubuntu does stuff like that. --KägeTorä - (影虎) (TALK) 08:07, 28 May 2011 (UTC)

There are a bunch of things that you might mean by "not recognized by Vista". Does the drive spin up at all? If not, then my guess would be that this is a hardware failure (new hardware, left edge of the bathtub curve) and the fact that it happened just after the installation was essentially a coincidence.
If it spins up, then you could try running Disk Administrator to see if you can find the partitions. If not, maybe your partition table has been munged.
If the drive spins up at all, you'll probably find you have a lot more flexibility by looking at it in Linux rather than Windows. Do "sudo blkid" to see if the partitions show up as block devices, "sudo /sbin/cfdisk /dev/sdc" (I'm guessing it'll be sdc -- that depends on what you see in the blkid output) to see the partitions. Maybe you can mount the partition that has the data you want to save from Linux, even if you can't from Windows; that would let you copy it somewhere.. If the partition table is hosed, you might be able to recover it with low-level manipulations in Linux, though you'd want to read up on it carefully and plan it out, to avoid doing further damage. --Trovatore (talk) 05:08, 28 May 2011 (UTC)
Well, I managed to boot from Ubuntu on the new disk.

/dev/sda1: UUID="3A704EB7704E7A21" TYPE="ntfs" /dev/sda2: LABEL="HP_RECOVERY" UUID="D28E5A388E5A14F7" TYPE="ntfs" /dev/sda5: UUID="fdfa46a7-0252-4b2f-bf95-c3e95c110fec" SEC_TYPE="ext2" TYPE="ext3" /dev/sda6: UUID="63bb042c-32c5-4c33-b74b-75e6b1b6aada" TYPE="swap" /dev/sdb1: UUID="e0c623f9-bd91-4757-ac4f-56058e8e666d" TYPE="ext2"

ext2 is the partition I made with the Ubuntu installation (which I am writing from now). What I am wanting is that the other 900GB on the HDD (complete with 100GB of stuff I have put on it) show up in Vista, so I can access it from Vista. I am not bothered about not being able to access the Ubuntu partition from Vista. I would be able to do that in my own way, if the drive were visible in Vista, which it isn't. KägeTorä - (影虎) (TALK) 07:42, 28 May 2011 (UTC)

OK, I'm not liking the fact that the ext2 partition is showing up as /dev/sdb1, suggesting that it's the first block device on /dev/sdb. That probably means you put the new partition at the beginning of the disk, which probably means that you nuked whatever was there before. I hope your data were not too valuable. If they were, you could try taking the disk to a data-recovery expert; when you made the ext2 filesystem it would have destroyed some data but maybe not everything. --Trovatore (talk) 08:38, 28 May 2011 (UTC)

Ah, yes, in hindsight, it was at the beginning of the disk. So.... I need to reformat. All the info that's on the disk itself is stuff I still have on windows, so it's no big deal. Just means I have to reformat the disk. Now.... how do I do that when Vista is not even recognizing its existence? --KägeTorä - (影虎) (TALK) 08:44, 28 May 2011 (UTC)

Actually, Ubuntu is unable to access the other 900GB on the disk, either. --KägeTorä - (影虎) (TALK) 08:54, 28 May 2011 (UTC)
Well, that may just be unpartitioned (free) space. Try /sbin/cfdisk /dev/sdb and see what it says. --Trovatore (talk) 08:57, 28 May 2011 (UTC)
You could also use /sbin/cfdisk to create an NTFS partition in the second 100GB on the disk (it'll be /dev/sdb2). Then you can go into Disk Administrator in Windows and format that for NTFS. That way you don't lose your Ubuntu partition. --Trovatore (talk) 08:59, 28 May 2011 (UTC)

That sounded like the idea I needed. However, all I get is:

FATAL ERROR: Cannot open disk drive
                         Press any key to exit cfdisk

I'm lost. --KägeTorä - (影虎) (TALK) 09:04, 28 May 2011 (UTC)

I have seen that error before. If I recall correctly, it's usually when I accidentally try to invoke cfdisk on a partition rather than the whole drive — something like /sbin/cfdisk /dev/sdb2 when what I should have typed is /sbin/cfdisk /dev/sdb. If that's not it, then I'm afraid I don't know. --Trovatore (talk) 09:12, 28 May 2011 (UTC)
Oh oh oh — or maybe you're not root? Try putting sudo in front of it. --Trovatore (talk) 09:13, 28 May 2011 (UTC)
You will never believe this. Looks like I formatted the entire drive when I put Linux on it........

cfdisk (util-linux-ng 2.17.2)

                             Disk Drive: /dev/sdb
                     Size: 1000204886016 bytes, 1000.2 GB
            Heads: 255   Sectors per Track: 63   Cylinders: 121601
   Name        Flags      Part Type  FS Type          [Label]        Size (MB)
                           Pri/Log   Free Space                           1.05*
   sdb1        Boot        Primary   Linux ext2                      100000.00*
   sdb2        Boot        Primary   Linux                           900201.23*

    [ Bootable ]  [  Delete  ]  [   Help   ]  [ Maximise ]  [  Print   ]
    [   Quit   ]  [   Type   ]  [  Units   ]  [  Write   ]
                         Delete the current partition

--KägeTorä - (影虎) (TALK) 09:27, 28 May 2011 (UTC)

Well, this only tells us that you have a /dev/sdb2 partition; you may not have "formatted" it (created a filesystem). You can find out with the following sequence:
sudo mkdir /media/sdb2
sudo mount /dev/sdb2 /media/sdb2
If there's a filesystem on /dev/sdb2, this will mount it; otherwise it will fail. If it mounts, look to see if there's anything important in it, then UNMOUNT IT AND THEN delete it in cfdisk. Then make yourself an NTFS partition, starting at the beginning of the free space (i.e. the end of /dev/sdb1) and write the partition table to disk. You might have to reboot after that. Then (if you have NTFS stuff in your Linux installation) you can use sudo mkntfs /dev/sdb2 to make an NTFS filesystem (="format" in Windows terminology), which should then show up in Windows. Or, after writing the partition table, you could reboot into Windows and open up Disk Administrator (it's in the control panel -- you might have to install it), look for the second partition on the disk, and format it from there. --Trovatore (talk) 09:41, 28 May 2011 (UTC)
Slight correction — the Windows version isn't called Disk Administrator anymore. I think that's what it was called in NT 4.0 or something. Now it's in Control Panel->System and Maintenance->Administrative Tools->Computer Management->Storage->Disk Management. Boy, they really hide it well :-/.
Also, I didn't quite explain everything you have to do in cfdisk to do what I suggested. The step that might not be obvious is, after you go to New and say what size partition you want and where, you have to go to Type and tell it that it's an NTFS partition. Then you have to go to Write, and when it asks you yes or no, type out the word "yes" (not "y"). cfdisk is a little balky, which is probably good given how much power it has to mess things up if you do it wrong. But it's possible you'd find gparted more intuitive, especially if you're used to Windows. --Trovatore (talk) 10:15, 28 May 2011 (UTC)
Right, I have partitioned the disk again (in Ubuntu, using the steps you suggested), and now I am able to see the existence of the disk from Vista, but am unable to make the partition (now 800GB) available for use from Vista, because I am now having the perennial problem of Windows loving to tell people who have Admin rights like me, that they don't have admin rights. How Microsoft continues to even exist is beyond me. --KägeTorä - (影虎) (TALK) 10:22, 28 May 2011 (UTC)

Thanks, Trovatore, you've been a star! All fixed now! --KägeTorä - (影虎) (TALK) 10:28, 28 May 2011 (UTC)

Data matrix "bar codes"[edit]

A co-worker of mine on another shift has taped a data matrix type bar code onto the cabinet over his desk. Is there a way to find out what it is the code for? Can I scan it with my smartphone somehow? If not for curiosity, I'd like to know so that I can let a little air out of his smugness. Dismas|(talk) 01:39, 28 May 2011 (UTC)

If you mean a QR code then yes, your smartphone should decipher it for you. It may or may not decipher other Data Matrix patterns, though. Try it ! StuRat (talk) 07:00, 28 May 2011 (UTC)
That's the link I was looking for but figured I was misremembering the name of it and gave the link for data matrix. Now... to figure out how to do that on my phone. I have an Android phone and an iPhone available to me. Thanks! Dismas|(talk) 07:07, 28 May 2011 (UTC)
Got it! Thanks again! Dismas|(talk) 07:11, 28 May 2011 (UTC)
You're welcome. I will mark this Q resolved. StuRat (talk) 07:48, 28 May 2011 (UTC)

Regex gurus needed[edit]

Hi there folks, I'm a neophyte with regular expressions and need some pointers. What I'm trying to get is a regex expression that matches {{Extra album cover}} when there is no cover displayed (either the field has no data or the image name is commented out). I've tried

{{Extra album cover[^}]+|\s+Cover\s+=\s+|[^}]*}}

And this broke my brain to create this version. I want it to match a string that starts "{{Extra album cover" has "| Cover = " in it (variable number of spaces) had has no uncommented image name between the = and the }} closing the template. Even a version that matches the case when there is only whitespace between the Cover = and a following | or }} would be good. I'd love help if possible thanks - Peripitus (Talk) 11:15, 28 May 2011 (UTC)

Many different regular expression syntaxes exist, but I assume this is a Perl (compatible) regex. In that case { and | are special characters, so you need to escape them.
The simple-case expression you requested would be something like \{\{Extra album cover[^}]+\|\s+Cover\s+=\s+(?:\|[^}]*)?}} (untested). I can't do the general case because I don't know the full grammar of MediaWiki articles. My impression is that it's a horrible mess, and mw:Markup_spec/BNF seems to bear that out. Perl regex syntax is also a nightmare. In theory, a completely correct regex probably exists, but good luck finding it. -- BenRG (talk) 19:39, 28 May 2011 (UTC)

This regex, in Javascript,

\{\{[Ee]xtra album cover[^}]*\|\s*[Cc]over\s*=\s*(<!--.*-->)?\s*[\|}]

matches all of the following:

{{Extra album cover | cover = }}
{{Extra album cover | asdfasdf | cover = | foo = bar}}
{{Extra album cover | asdfasdf | cover = <!-- myfile.jpg --> }}
{{Extra album cover | asdfasdf | cover = <!-- myfile.jpg --> | foo = bar}}
{{extra album cover|cover=}}
{{extra album cover|cover=<!--myfile.jpg-->|foo=}}

and does not match

{{Extra album cover | asdfasdf | cover = myfile.jpg | foo = bar}}

You may need to use a multi-line flag like "m" since the templates are often written on multiple lines. Note that the above does not match the empty template {{Extra album cover}} or cases where the "cover" attribute is not already there. IANE. Riggr Mortis (talk) 23:49, 28 May 2011 (UTC)

Wow, thank you both. I think I understand them as written but would not have got there for a very very long time, if at all. Thanks again - Peripitus (Talk) 23:58, 28 May 2011 (UTC)
Hope it helps. Um, the regex I gave above did not display correctly; the HTML "comment" part was treated literally, so it didn't show. I've added "nowiki" around it this time. Riggr Mortis (talk) 00:23, 29 May 2011 (UTC)

Half-life 2/Steam question[edit]

I've been re-organising my home office and found a copy of Half-life 2 that my Father in Law gave to me - I fancy a quick blast but remembered that steam games can only be registered once? If I tried to install it, it will fail right? --Cameron Scott (talk) 11:39, 28 May 2011 (UTC)

Yes and no? I believe they CD-key can only be registered once to a steam account, yes, but I believe you can install it and play it on a new/different PC, provided you use the same steam account. I think the activation of the game follows the steam account, not the computer. (You might not even need to use the disc - if you have download the steam client and login, it may allow you to download the game directly. I know Blizzard has this for some of their games :-D ) Avicennasis @ 11:56, 24 Iyar 5771 / 28 May 2011 (UTC)
Yes indeed. At least for Valve's own games you don't need the disk, and you can install them on multiple machines with the same steam account (Steam doesn't let you use the same licence concurrently, naturally). This may not be the case for non-Valve games on Steam, like Arkham Asylum, which have additional copy protection schemes. -- Finlay McWalterTalk 13:15, 28 May 2011 (UTC)
The above is all correct. If you remember your Steam account name and password, you don't need the HL2 discs or registration code at all; just install Steam on any machine in the world, log in, and choose to install HL2, and after a long download, you're in business. Comet Tuttle (talk) 17:20, 29 May 2011 (UTC)

Making copy of windows 7 disc[edit]

More adventures in my home office (see above) - I have found my Windows 7 Disc - I want to make a copy of it so that if the original gets scratched I have a copy - what's the easiest way to do it? --Cameron Scott (talk) 11:43, 28 May 2011 (UTC)

A program like ImgBurn (free) will allow you to make a copy in ISO format, then burn that to a new disc - a simple process and gives you an exact duplicate, both on disc and in the ISO file. I haven't used the newer versions - you might be able to burn straight from disc to disc now. Avicennasis @ 12:00, 24 Iyar 5771 / 28 May 2011 (UTC)
Wouldnt the Win7 disk be likely to have uncopyable track(s) so that the software can verify its an original disk and not a copy? So it wouldnt be identical? (talk) 20:40, 31 May 2011 (UTC)

Incorrect 'Password is Incorrect' Message in Thunderbird[edit]


I'm having trouble checking my email using Thunderbird. My email is a Yahoo BT account (you know, the one that BT says they will give you for free, even though Yahoo accounts are free anyway). Thunderbird is suddenly telling me that my password is wrong. So, using the browser to login to my free BT Yahoo account, using the password I have been using for two years, I am able to change the password to a new passoword - and then inputting this brand new password into Thunderbird, I get the same message telling me the password is wrong. Can anyone help out here? --KägeTorä - (影虎) (TALK) 13:24, 28 May 2011 (UTC)

-- Edit - doesn't matter. Sorted it out. --KägeTorä - (影虎) (TALK) 14:08, 28 May 2011 (UTC)

PC Game Dust Tale of the wired west[edit]

This question was originally posted on the help desk [1] - I moved it over here.  Chzz  ►  15:55, 28 May 2011 (UTC)

I Love the game, I am hooked but now I have Windows XP and cannot play the Game. My question is there an up to date version of the game or a patch so I can play the version I have? If I have to purchase the game again, so be it, unless there is a down load that would be to quote Tony the Tiger GREAT!!!!! So I hope you can help or steer me to the right Phone # or E-Mail to get the mission accomplished. Please hurry because again I Love the game....Terry — Preceding unsigned comment added by (talk) 15:52, 28 May 2011 (UTC)

Our article on this is Dust: A Tale of the Wired West. Can you describe what exactly happens when you try to play the game under Windows XP? (If you have access to a PC that has Windows 7, its Windows 95 compatibility mode might fix whatever problems you are encountering.) Comet Tuttle (talk) 17:42, 28 May 2011 (UTC)
After writing that, I googled Dust: A Tale of the Wired West "windows xp" and the first google hit is this forum thread in which one poster advises how to, under Windows XP, set the DUST application to run in 256 colors only and run as administrator, which supposedly gets it working. Comet Tuttle (talk) 17:45, 28 May 2011 (UTC)

Supressing output to the Windows XP Command Prompt[edit]

I issue the following PyWikipedia command:

C:/pywikipedia/ -page:User:StuRat/X_MOVE -text:"\n MOVE_X1=1\n" -always

Which works, but also produces this messy screen output:

Messy screen output 1
unicode test: triggers problem #3081100
Loading User:StuRat/X MOVE...

>>> User:StuRat/X MOVE <<<
+  MOVE_X1=1

WARNING: Your account on wikipedia:en does not have a bot flag. Its edits will be visible in the recent changes and it may get blocked.
Sleeping for 7.6 seconds, 2011-05-28 17:17:43
Updating page User:StuRat/X MOVE via API
Pausing 9 seconds due to database server lag.
Updating page User:StuRat/X MOVE via API

I would like to pare that down to this:

Sleeping for 7.6 seconds, 2011-05-28 17:17:43
Pausing 9 seconds due to database server lag.

So, I tried redirecting the output to a file, like so:

C:/pywikipedia/ -page:User:StuRat/X_MOVE -text:"\n MOVE_X1=1\n" -always > junk.txt

But this was the result:

Messy screen output 2
Loading User:StuRat/X MOVE...

>>> ♥{lightpurple}User:StuRat/X MOVE♥{default} <<<
♥{lightgreen}+♥{default}  MOVE_X1=1
WARNING: Your account on wikipedia:en does not have a bot flag. Its edits will be visible in the recent changes and it may get blocked.
Sleeping for 7.5 seconds, 2011-05-28 18:38:44
Updating page User:StuRat/X MOVE via API
Pausing 9 seconds due to database server lag.
Updating page User:StuRat/X MOVE via API

Other than somehow messing up the color changes, this didn't seem to do anything beyond suppressing the first print line. So:

1) How can I suppress all the screen prints ?

2) How can I suppress all the prints except those containing (or better yet, starting with) the words "Sleeping" or "Pausing" ? StuRat (talk) 22:48, 28 May 2011 (UTC)

You can suppress the output by appending > nul (if you're using cmd.exe or 4NT) or > /dev/null (if you're using a Cygwin shell such as bash).
You can display only the lines that start with "Sleeping" or "Pausing" by appending | grep -P "^Sleeping|^Pausing" (if you have GNU grep installed). Unfortunately, the output lines may be delayed significantly, because most programs will buffer their output in large chunks if they aren't writing to a TTY/console, and the pipe to grep is not a TTY/console.
This assumes that the script writes logging messages to standard output. If it uses standard error, you can add 2>&1 to redirect stderr to stdout. This has to go before the pipe symbol (|). -- BenRG (talk) 00:18, 29 May 2011 (UTC)

I tried adding "> nul", like so:

C:/pywikipedia/ -page:User:StuRat/X_MOVE -text:"\n MOVE_X1=1\n" -always > nul

I got this result:

Messy screen output 3
Loading User:StuRat/X MOVE...

>>> User:StuRat/X MOVE <<<
+  MOVE_X1=1
WARNING: Your account on wikipedia:en does not have a bot flag. Its edits will be visible in the recent changes and it may get blocked.
Sleeping for 7.7 seconds, 2011-05-28 23:05:11
Updating page User:StuRat/X MOVE via API
Pausing 9 seconds due to database server lag.
Updating page User:StuRat/X MOVE via API

I tried adding in "2>&1", like this:

C:/pywikipedia/ -page:User:StuRat/X_MOVE -text:"\n MOVE_X1=1\n" -always 2>&1

This was the screen output:

Messy screen output 4
unicode test: triggers problem #3081100
Loading User:StuRat/X MOVE...

>>> User:StuRat/X MOVE <<<
+  MOVE_X1=1
WARNING: Your account on wikipedia:en does not have a bot flag. Its edits will be visible in the recent changes and it may get blocked.
Sleeping for 7.7 seconds, 2011-05-28 23:10:11
Updating page User:StuRat/X MOVE via API

So neither one of those worked. I seem to have grep, but it's not working for me. First I tried this grep:

C:/pywikipedia/ -page:User:StuRat/X_MOVE -text:"\n MOVE_X1=1\n" -always | grep -P "^Sleeping|^Pausing"

Which produced this error:

'C:' is not recognized as an internal or external command,
operable program or batch file.

I then tried the grep along with "2>&1":

C:/pywikipedia/ -page:User:StuRat/X_MOVE -text:"\n MOVE_X1=1\n" -always 2>&1 | grep -P "^Sleeping|^Pausing"

This produced no output at all, and, judging from how quickly the prompt came back, the command didn't execute. So, it looks like that got the same error, but suppressed it. What am I doing wrong ? StuRat (talk) 03:22, 29 May 2011 (UTC)

The failure of the first one probably means output is going to stderr. The second one failed because you left out >nul; you need to write 2>&1 >nul. The third and fourth failed because you used forward slashes in the executable path, which are being interpreted as command-line options. Use backslashes. I don't know why the forward slashes work when you don't pipe to grep, but generally they won't work. -- BenRG (talk) 06:27, 29 May 2011 (UTC)

OK, I changed the slashes as follows:

C:\pywikipedia\ -page:User:StuRat/X_MOVE -text:"\n MOVE_X1=1\n" -always 2>&1 | grep -P "^Sleeping|^Pausing"

It then complained "Error: Invalid option -P", so I took out the "-P" (but left in the rest of the grep). That worked ! What was the "-P" supposed to do, anyway ? StuRat (talk) 10:33, 29 May 2011 (UTC)

-P means to use Perl regex syntax. I added it because Perl uses | for alternatives, some other syntaxes use \| instead, and I didn't want to deal with differences in backslash handling in different shells. You have an older or off-brand grep with fewer options. I don't know why | alone still worked. Maybe I'm wrong about the default grep syntax, which I never use. -- BenRG (talk) 17:06, 29 May 2011 (UTC)
OK, thanks. StuRat (talk) 06:10, 30 May 2011 (UTC)