Wikipedia:Reference desk/Archives/Computing/2011 December 18

= December 18 =

Forcing www on a domain
Is there any way (using DNS alone) to redirect anyone who visits http://domain.com to http://www.mydomain.com? I am aware of .htaccess hacks, but I was looking to do this through domain settings alone. Thanks --Chachu207 talk to me 00:35, 18 December 2011 (UTC)
 * You can do this on a CNAME record, but is not a generic redirect for all possible names. Perhaps you can use a javascript proxy.pac or proxy config to do this for you for the generic x.com -> www.x.com.  Or not so long ago there was a DNS hijacking hack that altered peoples DNS settings to point to a bogus DNS server that directed people to an ad service. Graeme Bartlett (talk) 04:16, 18 December 2011 (UTC)


 * Though if you are going to do such hacky things, why not just use .htaccess? It's really a pretty easy option, as far as they go. I would do that well before I started using Javascript as a solution here... --Mr.98 (talk) 13:49, 19 December 2011 (UTC)

Android app permissions
Hi, on a Samsung Galaxy tablet, presumably the "Modify/delete USB storage contents" app permission refers only to any additional storage I might attach via the USB adaptor, does it? (And why isn't "read" mentioned, I wonder?) I mean, all apps can presumably use the onboard storage to their heart's content, can they? But they can never read other apps' onboard data? 31.53.244.201 (talk) 00:36, 18 December 2011 (UTC)


 * Oh, strange, I was just reading someone's reply to this, when now I notice someone else has just deleted it (here). Was that intentional? I thought it seemed a good answer. Did someone think it was incorrect? 31.53.244.201 (talk) 04:21, 18 December 2011 (UTC)
 * I don't know why it was removed, but I've restored my answer. APL (talk) 06:58, 18 December 2011 (UTC)


 * What you've said is essentially correct. The permission in question is "android.permission.WRITE_EXTERNAL_STORAGE", which allows writing to both external USB drives and SD cards. I believe that reading external storage does not require a permission. (Never tried it actually, but there isn't one on the list.)
 * As for onboard storage, yes, each app gets a data folder that is it allowed to read/write to, but no app can access another app's data folder. APL (talk) 02:27, 18 December 2011 (UTC)
 * I had accidentally deleted the two preceding comments due to fat fingers on a mobile device, and apologise profusely. Fifelfoo (talk) 07:11, 18 December 2011 (UTC)
 * No problem. APL (talk) 07:12, 18 December 2011 (UTC)
 * Not by some strange coincidence a Galaxy tablet using an app that requires the permission to modify/delete USB storage contents I guess? BTW the ability is rather useful since if you have a mobile device with a small amount of built in flash storage which despite the ultra low price of flash memory, some manufacturers seem to prefer for the lower end models, having the device store the data on the SD card rather then the built in memory is often preferable. From what I can tell, at least as of 2.2 and I believe 2.3, cards don't get the ability to store data on the SD card, even when you use the 'move to SD' function of Android. The data and some other 'essential' stuff is still stored on the internal storage (unless you root or otherwise modify the way your phone works). Of course some apps, despite allowing you to store the main game content on the SD and requiring the permission, seem to think it necessary to store 15MB of data on your internal storage. Yes I'm thinking of you Plants and Zombies (unless that's changed in a new verson)! Note that even if you have a more decent amount of storage, with some HD Gameloft? apps which use over 1GB (from what I've heard) of game content, being able to store on the SD is likely still useful to quite a few. Nil Einne (talk) 16:32, 18 December 2011 (UTC)


 * Well, my tablet has 32GB onboard storage, and no SD slot. I presume it would be possible to add more external storage via the USB adaptor but I have not tried it and would hope I never need to. Incidentally, that brings me to another question. When I connect the tablet to my PC via the USB adaptor, I see all the tablet's (visible) file system laid out in Windows Explorer, and can drag and drop and stuff. However, am I safe in assuming that this does not work the other way? In other words, apps on the tablet cannot ever see my PC's file system while connected (i.e. they don't see it as some sort of huge external storage device)? I certainly would not want that. (Gratuitous plug: the Galaxy 10.1 is one seriously sexy piece of kit...) 86.181.205.216 (talk) 21:44, 18 December 2011 (UTC)
 * That's correct. Most tablets are set up to work as a "mass storage device", so from the PC's point of view they act like a thumb drive or similar. That does not work the other way.
 * It wouldn't at all be theoretically impossible to make this work, but it would require special software specifically for that purpose on the PC.
 * (However, if your tablet came with special drivers you had to install on your PC, we can't guarantee those drivers aren't doing something strange, but such an unusual feature would probably be prominently advertised. ) APL (talk) 23:47, 18 December 2011 (UTC)
 * Thanks APL, really appreciate your advice. 86.181.205.216 (talk) 00:18, 19 December 2011 (UTC)

Screen Resolution
My 15.1 inch Dell laptop comes with Windows 7. The screen res has gone haywire for some reason. When I go to Display--> Screen Resolution, the display dropdown box shows "Generic PHP Monitor on Standard VGA Graphics Adapter" when it should actually show "Mobile PC Display". As a resut, I can't select 1366x768 res, and am forced to select 1024x768 res instead, which makes my screen looked stretched. Please Help. The mobile pc option just isn't there. How do I make it appear? 117.226.214.236 (talk) 13:01, 18 December 2011 (UTC)


 * You might try re-downloading and re-installing the display drivers. The exact one will depend on your computer model, but check the "support" section of the Dell website, find your laptop model on there, and there should be drivers to download. --Mr.98 (talk) 15:32, 18 December 2011 (UTC)


 * Another possibility is that you have both built-in graphics that handles the lower resolution and a graphics card that provides the higher res. If the graphics card has gone bad, then it reverts to the built-in graphics display.  If the graphics card is permanently damaged, it would need to be replaced.  However, if it just jiggled out of the slot, then pulling it all the way out and pushing it back in should fix the problem.  This is especially likely if you dropped the laptop or struck it recently.


 * Unfortunately, laptops aren't made to be user-serviceable, so taking it apart to check this out is risky and might cause other damage, so you might want to take it to a computer repair shop. However, before doing this, by all means try to reinstall the driver, in case that's the issue. StuRat (talk) 19:35, 18 December 2011 (UTC)


 * To find the driver, you might have got a DVD from Dell containing the drivers. Failing that, look on the bottom for the service tag and enter that into the support area of the Dell website for your country.  You should be able to download the driver from there.  Astronaut (talk) 05:05, 19 December 2011 (UTC)

macros/scripts
What language would be used to code macros/scripts that clients use to perform automated tasks with web pages? An example of such a task would be parsing the source code of a series of pages and retrieving information in or between certain HTML tags. Another example would be using data from a database to repeatedly fill in and submit a form, assuming there is no CAPTCHA. — Preceding unsigned comment added by 202.156.10.14 (talk) 17:16, 18 December 2011 (UTC)


 * Almost any language can be used for that; the tasks you describe are pretty straightforward in Python. -- Finlay McWalterჷTalk 17:18, 18 December 2011 (UTC)


 * And all of this can be made quite easy if you find a good web crawler/client class library for whatever language you use. One I have used for PHP is the Snoopy class, which makes automating form submission/data retrieval/cookie setting/etc. quite easy. I am sure there are similar class libraries for whatever language you want to use. --Mr.98 (talk) 17:48, 18 December 2011 (UTC)

HOW TO SAVE A PRINTER OUTPUT FROM A TASK MACHINE INTO A FILE
I have a task machine. The output from which is only available through a printer. Is there any device or method to save the data through the printer port into a file along with the printout. I am unable to modify the machine.I thought of connecting a two-channel device to the printor port and then connecting a printer to one of the channel and a new device to the other channel. So that I can save the data coming through the printer port into the device. — Preceding unsigned comment added by 117.199.2.182 (talk) 18:49, 18 December 2011 (UTC)


 * Questions:
 * What do you mean by "printer port"? Do you mean a parallel interface, or USB, or what?
 * What kind of printer is (or was) on that port (make, model)?
 * When you say you can't modify the machine - does that mean it's something like a cash register or factory-automation-thing, or is it a desktop windows PC that you simply don't have admin rights over?
 * Why do you want to do this? Is it because the printer is broken (and a replacement can't be sourced) or because you want to save jobs as well as print them?  What do you want to do with the saved jobs?  That's important, because it affects what kind of data you want to store.
 * -- Finlay McWalterჷTalk 19:01, 18 December 2011 (UTC)

Why ./ needed to run a compiled C programs
In Linux, why do I need to type ./a.out to run a compiled C program and not just a.out? --178.208.197.76 (talk) 19:13, 18 December 2011 (UTC)


 * I believe ./a.out means to run a.out in the current directory, while a.out means to search through the directories in the $PATH environment variable for it. Normally, the current directory is the first directory defined in the $PATH variable, but not always, so there can be a difference. StuRat (talk) 19:19, 18 December 2011 (UTC)
 * That is correct. If you just type, then Linux will keep searching for   in every directory in   until it finds one, and then execute it. If it doesn't find one, it will print out:  . But if you type  , then Linux will only search for   in the current directory, and if it finds it, then execute it. For some reason which I don't remember at the moment, the current directory  isn't in the path by default in Linux (even though it is in Windows). In theory, there's nothing stopping you from adding   to   in Linux, in which case just typing   will work, but it might go against some design principle that I don't remember at the moment. J I P  &#124; Talk 19:25, 18 December 2011 (UTC)
 * It's a security hole. If . appears in the path, it should be the last entry, otherwise it is possible to trick a user into running a trojan by giving it the same name as another program. Looie496 (talk) 19:30, 18 December 2011 (UTC)
 * Note: All this is true for any program in Linux, not just compiled C programs. It's a basic principle of how running programs in Linux works. J I P &#124; Talk 19:41, 18 December 2011 (UTC)
 * And when you're saying Linux you really mean bash. Shadowjams (talk) 20:29, 18 December 2011 (UTC)
 * As far as I know those things hold true for every commonly used shell. Looie496 (talk) 22:45, 18 December 2011 (UTC)
 * "Used shell" Looie? Why doesn't it work in a new shell? — Preceding unsigned comment added by 88.8.69.150 (talk) 14:13, 19 December 2011 (UTC)
 * Reps kops. A Finnish expression for laughing so hard you bang your head on the table. J I P &#124; Talk 15:47, 19 December 2011 (UTC)
 * It is a security hole for "." to appear anywhere on the path. In the attack Looie496 describes above, a malicious user can place a trojan with the same name as a commonly executed command, such as ls, in an "other readable" directory and then entice the victim to cd to that directory and execute the command. If "." appears in the path before the directory in which ls resides, then the trojun "./ls" is executed instead.  Placing "." at the end of the path is a little better, but the victim is still susceptible to a trojan named after a likely misspelling of a common command, such as "sl". The smart trojan will even reassure the victim with  . The attack can also occur on a single user machine if the victim untars an archive which contains a trojan, and accidentally mistypes a command.  You wouldn't type "./sl" unless you intended to run a command in the current directory, so get used to typing "./" before all commands in the current directory you do intend to run and keep "." out of your path.  This will also save headaches when you inadvertently create a local executable with the same name as some system command.  A common question of new Unix programmers is why the program they just wrote named "test" doesn't do anything.


 * Our PATH (variable) article mentions this exploit, but only states, "The current directory (.) is sometimes included as well, allowing programs residing in the current working directory to be executed directly. Superuser (root) accounts as a rule do not include it in the path, however, in order to prevent the accidental execution of scripts residing in the current directory. Executing such a program requires the deliberate use of a directory prefix (./) on the command name." All discussions of this exploit that I have read state that all users should omit "." from their path. This FAQ may not be an ideal reference. I'll see if I can find it mentioned in one of the O'Reilly books. -- ToE 21:40, 19 December 2011 (UTC)

a.out
Firstly, thanks for all your answers to my question above. I'm now wondering why the default output file from cc is a.out? Is .out the equivalent of .exe? If I rename the file or give it as a command line option, does it have to have the .out or any other extension or will any name do? --178.208.197.76 (talk) 21:43, 18 December 2011 (UTC)


 * It's an anachronism from at least the time of the PDP-7 in the late 1960s. The .out name scheme might very well have meant something back then, but now it's totally lost, and the only time you'll ever see it is this one weird case. We have an a.out article, which notes that the name was also used for the format of all compiled C executables (on some platforms), but now a.out persists only as a name. It's the C compiler's vestigial tail. -- Finlay McWalterჷTalk 21:51, 18 December 2011 (UTC)


 * (ec) The article a.out explains that the name is short for assembler output. There is no linux filename suffix corresponding to the .exe of Windows, your file may be called anything you like, as long as you make sure it has the file attributes of an executable file (chmod 755 filename). --NorwegianBluetalk 22:01, 18 December 2011 (UTC)
 * chmod +x filename would be better as it doesn't change the r & w permissions from your configure default. Astronaut (talk) 04:58, 19 December 2011 (UTC)