Wikipedia:Reference desk/Archives/Computing/2009 June 5

= June 5 =

force bash to expand arguments (Linux)
Is there any way to force bash to "expand" the arguments passed to a script?

Example:


 * Script 1: /home/hacktolive/dir1
 * Script 2: /home/hacktolive/dir2
 * Image:   /home/hacktolive/dir1/image.png

When I launch script 1, it then launches script 2, and passes the command-line arguments to it. The problem is that if I do /home/hacktolive/dir1/script1 ./image.png then script2 will try to look for image.png at /home/hacktolive/dir2 (as expected), while I wanted to expand ./image.png to: /home/hacktolive/dir1/image.png. I think part of the solution is having something like this on the script 2:

# try to sanitize arguments by changing to the dir of script 1 cd "$script1_path" # in this case script1_path is: /home/hacktolive/dir1 for var in "$@" do      args="$args $var" done

# we now launch the image viewer (args are the images to be opened) "$image_viewer_launcher" "$args"

However, this alone does not work, I still need to "force" bash to expand ./ to the proper location. (I have considered using readlink, however, that does not work, since I can't know if a command will be a file/location or anything else). Anyone know how to do this? (PS: This might sound a silly thing to do, but I wanted a similar feature on RUNZ, and no: I can't just launch script1 directly) Thanks. ___ Hacktolive (talk) 00:16, 5 June 2009 (UTC)


 * pwd will return the working directory -- echo `pwd` would return /home/hacktolive/dir1. You could simply prepend that to your path name. You would end up with /home/hacktolive/dir1/./image.png which should work fine (note, not tested as I'm at work and thus bashless, also bash is not my strong suit). --Polysylabic Pseudonym (talk) 06:14, 5 June 2009 (UTC)


 * Or see this page regarding the dotglob variable. In short, set the dotglob shell variable and the shell will kindly expand ./ to /home/hacktolive/dir1, clear dotglob to return to normal --Polysylabic Pseudonym (talk) 07:06, 5 June 2009 (UTC)
 * I just figured out that what I want is pretty much impossible to do in a "clean way".... Thanks anyway! Cheers. __ Hacktolive (talk) 21:27, 5 June 2009 (UTC)

Bit operators
I'm teaching myself Objective C. The book I'm using brings up bit operators in chapter 4. I understand the basic concept of them but I'm left wondering how often these are actually used! They seem rather... obscure? Or at least not used so often that they need to be taught so early on... Am I way off base or what? Dismas |(talk) 04:55, 5 June 2009 (UTC)


 * It depends on the field you're in - in some applications, they are VERY commonly used - in others, never. They are taught that early in most programming books because they are very similar to the usual +,-,*,/,% arithmetic operators - and it makes sense to teach them all at the same time.  I don't use Objective C - but they are the same as in C and C++.  In the past few days I've used bitwise operators in C++ to...
 * Allow my Arduino to control individual bits of an 8-bit port that's wired up to drive a pair of stepper motors for my CNC milling machine.
 * Pack a set of 128 skeletal mesh bone enable/disable bits into a small space so it can be efficiently transmitted to a vertex shader in the GPU of a graphics card.
 * Convert a floating point number into an nVidia-style 'half float' - and vice-versa.
 * ...for example! SteveBaker (talk) 05:27, 5 June 2009 (UTC)


 * Okay, thanks! So I'm guessing that I won't be using them too much...  I just want to write a few iPhone apps which have a minimal amount of math and mostly deal with moving text around.  Dismas |(talk) 05:59, 5 June 2009 (UTC)


 * Yes, bit operators are mostly used in rather "technical" programming. Recently I have written a library to encode/decode bitmaps (*.bmp files), and there I use bit operators to access/write to individual bits of bytes, which is neccessary. --Andreas Rejbrand (talk) 07:48, 5 June 2009 (UTC)


 * One use-case for bitwise operators that is not limited to certain fields of programming is to circumvent short-circuit evaluation. For example:


 * But even this is kind of limited to special cases. decltype (talk) 10:10, 5 June 2009 (UTC)


 * I don't know the iPhone API - I suspect that you'll find you need at least a passing knowledge of these things. I believe the iPhone uses OpenGL-ES for rendering.  That means that you'll see things like this code snippet (which clears the screen):

glClear ( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT ) ; glClearScreen ;


 * The two '|' operators in the first line are bitwise 'OR' operators that are being used to combine some flags into a single number. Admittedly, it doesn't take a huge amount of knowledge of boolean logic to understand what this means...but these operators do tend to slip into code in sneaky ways.  So I think you should learn about them.  Since you're certainly going to need to understand '&&', '||' and '!' - it's not a huge stretch to go from there to knowing about '&', '|' and '~', which are their bitwise cousins. SteveBaker (talk) 14:18, 5 June 2009 (UTC)

How to connect SQL database to matlab GUI????????
How to connect SQL database to matlab GUI ???? --Lbnnirmal (talk) 05:25, 5 June 2009 (UTC)

watching TV on my laptop
How would I go about doing this, so I can simply watch TV broadcasts through my computer instead of a TV. At the moment I get Freewire, but it seems that only works at university, and when I go home, I'll be sharing a bedroom with my younger brother, and don't want to bother him by watching our TV all the time, particularly not late at night, so I though if I could get TV channels through my laptop instead, i could sit where I wanted to watch, and wear my headphones so I don't disturb anyone else. Last time I was at home I searched all over the internet and only found lots of junk that didn't work. Does anyone know any place that offers this service. It sounds like quite a simple thing to do, just shifting the signal form one screen to another, I just can't find anyone else that can do it. 148.197.114.207 (talk) 11:53, 5 June 2009 (UTC)
 * You could get a TV tuner card. Hauppage makes some good USB ones.  If you have a Mac, I reccomend going with EyeTV.  Their software is excellent. 206.131.39.6 (talk) 16:54, 5 June 2009 (UTC)

OP again: A USB tuner card, would that plug into the USB port, or would I have to cut the computer in half to get it in? And where would I have to go to get one? 88.108.105.188 (talk) 10:11, 7 June 2009 (UTC)


 * Our article on TV tuner card mentions USB tuners at hdhomerun) and HAVA. However you need to be aware about screen resolution and life of the monitor, see an earlier discussion. It also says it is not as simple as shifting the signal from one screen to another. Jay (talk) 10:04, 8 June 2009 (UTC)

Last question. I think I remember something about my laptop already being able to get TV, or that may have been another I was considering getting, at least I have still been able to get Freewire TV through it, so is it possible my computer already has this stuff somewhere, and if so, how would I get to the broadcasts? Is there a website I can go on or something? 88.108.38.27 (talk) 10:43, 8 June 2009 (UTC)

There are streaming website content as well, such as www.hulu.com which are full broadcasts available for download. This will not do live broadcasts, but may be of interest as it is free. Otherwise, you would need a TV tuner card (a piece of hardware either through USB, PCMCIA, or maybe PCI slot)

XML XSD Schema - what is the namespace attribute of the import statement for
I have a schema that has a default name space:



I find that to access elements in the included schema I have to ad a definition refering to the name in the included XSD



It doesn't work if I use

xmlns:subxsd="http://www.example.org/includedName"

What is the namespace attribute on the include for?

Loadrunner - Vugen script explanation?
Hi, I'm using LoadRunner's VUGen script. I was wondering if there was some document that explained the syntax and the different functions that exist within the script so that if necessary I can make modifications to the recordings. I can't seem to find any document anywhere on the details of this script language. If someone could help me I'd appreciate it.

Thanks, Chris M. (talk) 13:23, 5 June 2009 (UTC)

Games that won't run on nVidia 7000-series graphics cards.
I'm trying to make the case that nVidia "shader model 2.0a" graphics cards (ie 7000-series and earlier) are obsolete. I need to get a list of maybe a dozen modern games that won't run on 7000 cards (or at least that say "shader model 3 or later" or "nVidia 8000 series or later" on their boxes). I bet a bunch of people here have a row of PC game boxes on their shelves - I'd REALLY appreciate it if you'd take a moment to look at the "minimum spec" info on the side. Thanks! SteveBaker (talk) 14:02, 5 June 2009 (UTC)


 * 7300GT: GTAIV will not play; Bioshock will, but playable only at very lowest settings. Hopper Mine (talk) 14:49, 5 June 2009 (UTC)


 * The only reason GTAIV won't run is because it's so crappily ported. There are very few (if any, I don't know of any) games that REQUIRES DirectX10 - even Crysis doesn't require DirectX 10 hardware, so I don't think it'd make much of an argument here. --antilivedT 05:27, 6 June 2009 (UTC)


 * I'm not home right now, so I can't look at the actual games, but the oldest cards on the 7000 series are literally four years old. That's a long time in game graphics, so I think your case is pretty valid. Steve, for an easy way to get a lot of the data you need, you may want to check out the various games on Steam -- they list minimum requirements. (I just glanced at one,Splinter Cell: Double Agent (on sale right now, and super cheap!), and that requires a Shader 3.0-enabled video card. It's three years old, too. -- Captain Disdain (talk) 12:05, 6 June 2009 (UTC)


 * But the thing is the 7-series support shader model 3 too (hell even my old 6600GT supports shader model 3 (DirectX9) ). --antilivedT 12:32, 6 June 2009 (UTC)


 * GTA IV? Yeah, it'll run, although expect a slideshow on 7-series Nvidia cards. Double Agent also seems to be poorly-coded, too. I experienced framerate issues as well as fatal errors while trying to run the game. Blake Gripling (talk) 12:37, 6 June 2009 (UTC)


 * As the commentators above has suggest, I think you've confused your shader models. 6 and 7 series both supported 3 (as did the ATI x1*** series). The FX was SM2.0a and they were always POS anyway. ATI X700 and X800 and X850 are SM2.0b which were perhaps those that suffered the most. Several games, especially a few with the Unreal Engine 3 (which did support SM2.0x but was a bit more work to implement IIRC) like Bioshock required SM3.0 which was controversial at the time, especially because they were still relatively recent cards and better then cards like the 6600GT which could usually play these games acceptably. In the Bioshock case, there was enough interest that some people even started to hack the shaders which achieved acceptable although far from perfect results. Things have moved on since then. But still while I would agree, SM2.0a is obsolete, I'm not so sure about SM2.0b or even SM2.0 (since the Radeon 9800XT was quite a decent and popular card, and quite a few socket 939 mobos were AGP so it's not like they're all single core). The X850XT is perhaps a bit better then a 7600GT (other then the lack of SM3.0) which is IMHO far from obselete. And both are probably better then a 8500GT or 2600Pro. I think a lot depends on what sort of game you're referring to. If the sole purpose of the game is for eye candy and it has no story or any other redeeming quality then I would agree the cards can be considered obsolete. But for games which actually are trying to get a wider audience then I would say it's a bad idea to cut out such a segment of the market. IMHO anyway, reviewer sites are often a bit unrealistic. There are a lot of people who are willing to play a game at a lowish resolution with lowish settings if it's a decent game. Even more so in developing countries (although a fair number of these will pirate the game, not all, and in any case, they're even more likely to pirate the game if they have to upgrade the GPU). Anyone who says you need a 8800/HD4600 to enjoy most modern games IMHO does not represent a significant percentage of gamers. However if the game is not going to be released for over a year then perhaps SM2.0x would be obsolete by then. (Definitely I think, those who abandoned SM2.0x in 2007 made a big mistake.) P.S. If you're referring to DX10 only, then the only game I know of that is is Stormrise, not exactly a good example to follow (okay the game has far bigger problems but still it shows the kind of people who think DX10 only is a good idea probably aren't the smartest designers) P.P.S. In terms of SM3.0 remember that the 7 series includes the 7900 and on the ATI side the x1900/x1950. These are hardly bad cards and particularly since many people weren't impressed with the 8600 series and ATI HD2600 series were probably bought in fair numbers near their end of life by people who aren't the kind to upgrade every year. Nil Einne (talk) 09:19, 7 June 2009 (UTC)


 * Not really a games-issue (Well, GPGPU code can be used for game logic), but my 7600GS will not run CUDA. (I bought it because it's the most advanced card that came with an AGP interface after my Ti4600 died... wow, dinosaur system!)  CUDA and SLI are supported only by the 8800s and above, I think.  Nimur (talk) 13:14, 11 June 2009 (UTC)

Non-Existing Drives in Windows Vista
I'm running Windows Vista Home Premium Edition. A few months ago, I connected an MP3 player to my PC. When it installed, it added it as a new drive (letter F). That's fine, but every time I reconnected the drive, it added another drive (letters G, H, and I). I've never connected that device since then (I don't even have that MP3 player anymore), but those drives still show up on my computer even though they're not functional. I can remove them by going to "Safely remove hardware," but the next time I reboot, the drives show up again. Is there a way to get rid of them permanently? —Cswrye (talk) 16:03, 5 June 2009 (UTC)

Bash output errors
When i type in;

I get the following warning;

Now this does not seem to affect the program, as in the program works just fine, but it does kinda make the output look bad with all those warnings. Is there a way i can hide this warning? Or fix it?

System; Dell d610 running Backtrack3 Smileyhill (talk) 17:09, 5 June 2009 (UTC)


 * I think a missing font file is the problem. Try installing some additional font packages, making sure /usr/share/fonts/X11/misc (or wherever nil2.pcf.gz lives) is being found by the font server, or using a different terminal.  A brute force solution would be to redirect your standard error output to the bit bucket:

xterm -fn fixed -title "Calculating" -geom +0-0 -e "./calculator $var01 $var02 $var03" 2>/dev/null &
 * --Sean 20:28, 5 June 2009 (UTC)


 * thanks, i will give the brute force thing a try. As for installing stuff i am on a live cd. Smileyhill (talk) 20:36, 5 June 2009 (UTC)


 * Thank you, forcing the output in to the blender of oblivion worked very well. My program is now perfect!Smileyhill (talk) 20:54, 5 June 2009 (UTC)


 * The trouble with just redirecting stderr away to null is that it might actually contain useful errors as well as the annoying one you're trying to get rid of. If you think you'll be distributing the program to others, or using it yourself in the long term, you'd be better to redirect stderr to a log file (e.g.  2> /var/log/calc_error.log), and use logrotate to manage that logfile. That way you can ignore specious errors in normal use, but they're still there in the logfile if things genuinely start to misbehave. 87.112.85.8 (talk) 14:39, 6 June 2009 (UTC)


 * That is a fantastic idea. In fact i just ran in to an error where the program was not working. and because of those redirects it took me a while to figure out what the problem was (i forgot to end an 'if' statement with 'fi'). Now the only problem with redirecting it to the systems log file is that i will be mainly using this on a live cd. Altho i might be running the program from a usb stick, so i can make my own log file. Thanks! Smileyhill (talk) 23:33, 6 June 2009 (UTC)

Serif WebPlus User to User Help
(Advertisement deleted)


 * Welcome to the Wikipedia Reference Desk. Your advertisement has been removed.  This is not a chat forum or a place to put ads; it is a reference desk, where other Wikipedia editors can try to answer your questions.  See the text at the top of the page if you need more information about this web page.  Tempshill (talk) 20:08, 5 June 2009 (UTC)

Searching IMDb
I'm sure you can search IMDb using 'keywords' only. For example if I wanted to look at a list of films about football, I could just type 'football' into their keyword search field and the list would appear. But I'll be damned if I can find that feature now. (I am also an IMDbPRO user if this makes a difference).Popcorn II (talk) 18:38, 5 June 2009 (UTC)


 * Maybe this power search page? -- LarryMac  | Talk  19:12, 5 June 2009 (UTC)


 * You can also do a site-specific Google search with "". --Sean 20:30, 5 June 2009 (UTC)


 * Quite a few IMDB features are only available to paying users...perhaps this is one of them? SteveBaker (talk) 02:01, 6 June 2009 (UTC)


 * I went to a random IMDb page and clicked on one of the keywords shown; it took me to ; from there it was a short step to a search page. —Tamfang (talk) 04:45, 8 June 2009 (UTC)

Instance methods in Java
Hello! I'm new to Java and have a question. I see a lot of instance methods in the Java API that operate on objects without having the object as one of its arguments, e.g., "this is a string".length. Could someone give me an example of how to write a method like this? The only way I know how to accomplish this is

public class Example { public Example { int x = 5; int y = 3; }  public Example changeExample(Example exOne, int newX, int newY) { exOne.x = newX; exOne.y = newY; return exOne; } }

Then, to access changeExample :

Example exam = new Example; exam = changeExample(exam, 6, 11);

Which is really redundant and seems like very bad code. Can someone show me how to rewrite changeExample so that I can call it as exam.changeExample(6, 11)? Thank you!--el Aprel (facta-facienda) 19:14, 5 June 2009 (UTC)


 * Don't include the Example class in the parameters. Just use the two ints.  Then, in your code, you use exam.changeExample(6,11).  In the function itself, you use "this" instead of "exOne" and don't return anything. --  k a i n a w &trade; 19:22, 5 June 2009 (UTC)


 * Yep. If it helps conceptually, think of the method invocation as a message you're sending to an instance of Example.  In this case, you're telling it to modify itself with your new values. Friday (talk) 19:28, 5 June 2009 (UTC)


 * You should also add x and y as data members of Example, rather than as local variables in the constructor:

public class Example { int x;  int y;   public Example { x = 5; y = 3; }  // ...  }
 * --Sean 20:36, 5 June 2009 (UTC)


 * So, if I understand correctly, the method's code should look like this, right?:

public void changeExample(int newX, int newY) { this.x = newX; this.y = newY; } and it can be invoked by exam.changeExample(6, 11)--el Aprel (facta-facienda) 21:58, 5 June 2009 (UTC)
 * Yes. You can also omit the "this." and just do "x = newX;" -- the compiler knows there is a "x" field in scope. Though you could also rename the parameter newX to x, then you'd need "this.x = x;" because "x = x;" would assign the parameter to the parameter, with no effect. Sometimes a redundant "this." is used to underline that a field is being used, usually it is omitted as clutter. Matter of style. Fields are also almost always declared "private" or "protected" so that they can be manipulated only through the methods. 62.78.198.48 (talk) 09:36, 6 June 2009 (UTC)

Thanks everyone!--el Aprel (facta-facienda) 18:13, 6 June 2009 (UTC)

IE history security
I'm using IE7/8 for my Internet needs on two 32-bit xp PCs with pathches and service packs loaded, etc. Assuming no spyware,

Is it possible, for a web site to know what sites are also open in other browser tabs?

If a page is open in a tab and without following a hyperlink but by directly typing a new address, can the new site get what other page(s) were previously open in that tab or that instance of the browser?

Thank you very much!! 88.242.255.234 (talk) 19:30, 5 June 2009 (UTC)


 * Well, it's kind of complicated.
 * With Javascript, no, you can't access that.
 * With cookies, yes, a site could hypothetically do that, if there were shared cookies it was able to access.
 * With browser applets and plugins, it's probably possible. --98.217.14.211 (talk) 19:53, 5 June 2009 (UTC)


 * I've recently read an article on a website (forgot what) that runs through a list of porn sites and outputs a list of them that the user's been on to by exploiting the fact that browsers change the colour of the link when you've already clicked it. Therefore you can use javascript to read the colour of the link and iterates through a whole list, guessing your browsing history. So by extension it is theoretically possible to do something you've described in almost all browsers, but only if you've never visited the site before (so the link changes colour when you do visit the site). That's very impractical in practice though so I wouldn't worry about it. --antilivedT 10:17, 8 June 2009 (UTC)

Second internal hard drive on a laptop
Hello,

I have an HP Pavilion dv9700t laptop which came with one Western Digital SATA 250GB 5400rpm hard drive when I bought it last year. The laptop has a second hard drive bay, which is currently empty. I am considering getting a mobile hard drive that would be faster and have a greater capacity than my existing one (probably a SATA-II 500GB 7200rpm Seagate). However, I have heard that if I add it to my second bay, this may cause some hardware compatibility issues. Some people say that both hard drives on an HP laptop have to be of the same capacity, others say that they have to have equal speed. I haven't heard anything concrete on the issue, however; even the guy on HP customer support chat didn't help me much. I would like to know if this would really cause any compatibility issues. Please let me know. Thanks.  A R  TYOM   23:21, 5 June 2009 (UTC)


 * The HP manual about hard disks on their laptops that's linked to at the dv9700t product page talks about installing a new hard disk and doesn't mention anything about the drives having to be the same capacity or speed. I am not familiar with HP laptops, but would be surprised if this were a requirement.  The claims you have heard sound more like requirements for setting up a mirror-drive RAID.  If you just want to add a D: drive to your system and don't care about a RAID, then you should be fine adding any kind of hard disk to it.  Tempshill (talk) 02:57, 6 June 2009 (UTC)


 * Thanks for your reply! I had seen that manual before, but I thought that it only intended to show how to replace a hard drive, and that's why it didn't mention if there are any requirements. Well, I'll probably buy one and see how it goes.  A R  TYOM   18:52, 6 June 2009 (UTC)