Archive for October, 2006

Python – os.popen Does Not Work with Parameters Inside Quotes When Command is in Quotes

Wednesday, October 4th, 2006

To be honest, all I really know is that this python code returns ” for me,

[Dbg]>>> print command
"C:\automated tasks\GoldMine_Replace\GoldMine_Replace.exe" -lg -pfd5 -r"3XDYQ2#PK [Dbg]>>> os.popen(command).read()
''

while running the same command at the DOS prompt returns good stuff.
C:\>"C:\automated tasks\GoldMine_Replace\GoldMine_Replace.exe" -lg -pfd5 -r"3XDYQ2#PK Success

Additionally this Python bug seems to imply that os.system and the os.popen's just don't work quite right on Windows.

But don't get frusterated. Just do a cheap workaround and move/rename your executable (put it in a batch file if you have to) so that you don't need to put the command in quotes. That means making it have no spaces in it's filepath. That's what worked for me. I just moved the executable GoldMine_Replace.exe to the C:\ directory.

There's also a bit of discussion here but no real insight (just people claiming this problem doesn't exist?)

Easily Redirect a Whole Directory on Your Website to Somewhere Else

Sunday, October 1st, 2006

I hunkered down for a whole night of trying to redirect people visiting http://www.blendedtechnologies.com/justoneclubcard/ over to my new domain www.justoneclubcard.com. I wanted everything inside of it like http://www.blendedtechnologies.com/justoneclubcard/index.py and even including all those CGI GET paramters to seamlessly be transferred over to the new domain.

Well, I did it, and it was easy!, Check those links in the last paragraph if you don’t believe me ;-)

This site explained it best. Ultimately it was as simple as adding the following line to my .htaccess file in my root directory of the Blended Technologies website:
Redirect /justoneclubcard http://www.justoneclubcard.com/

Optional Explaination
So the line above is saying to send any browser requesting the directory /justoneclubcard over to http://www.justoneclubcard.com/. And /justoneclubcard corresponds to the external URL of http://www.blendedtechnologies.com/justoneclubcard/. The .htaccess file just doesn’t need to see the http://www.blendedtechnologies.com/ part because that’s what / means to it.

If you’re not familiar with the .htaccess file, here’s a good primer to get you started.