Hashemian Blog
Web Tools, Financial Markets, Technology
Sunday, August 19, 2007
IP address and Host name Scripts
As some of you know, this site contains several utilities in the tools section. One of these tools is JavaScript Visitor IP Address and Host Name. It's a simple JavaScript block that can be placed inside any web page and it displays or prints the visitor's IP address and host name.
As is with the rest of the tools, this one was also born out of necessity and I decided to share it with everyone. But some people are not comfortable putting my scripts on their site. That's cool and I don’t blame them, they don’t know me. So here I am going to explain how to display or print the user's IP address and host name using a number of server-side technologies.
The keyword here is "server-side". That's right, there is no way you can glean that information from client-side JavaScript. Even my JavaScript utility uses server-side calls to obtain the data and then packages it up in JavaScript format and streams it back. If your site supports server-side scripting, then chances are one of the following will do the job for you.
Perl:print "IP: $ENV{'REMOTE_ADDR'}<br>Host: $ENV{'REMOTE_HOST'}"; SSI:IP: <!--#echo var="REMOTE_ADDR"--><br>Host: <!--#echo var="REMOTE_HOST"--> PHP:<?= "IP: {$_SERVER['REMOTE_ADDR']}<br>Host: {$_SERVER['REMOTE_HOST']}" ?> ASP:<%= "IP: " + Request.ServerVariables("REMOTE_ADDR") + "<br>Host: " + Request.ServerVariables("REMOTE_HOST") %> ASP.NET:<%= "IP: " + Request.UserHostAddress + "<br>Host: " + Request.UserHostName %> Python:print "IP: " + cgi.os.environ["REMOTE_ADDR"] + "<br>Host: " + cgi.os.environ["REMOTE_HOST"] Ruby:print "IP: " + ENV["REMOTE_ADDR"] + "<br>Host: " + ENV["REMOTE_HOST"] JSP:<%= "IP: " + request.getRemoteAddr() + "<br>Host: " + request.getRemoteHost() %> Java Servlet:out.println("IP: " + request.getRemoteAddr() + "<br>Host: " + request.getRemoteHost()); A common issue with the above calls is that in many cases host names may be returned as IP addresses or nothing at all. In some cases that is because no reverse record for a client's IP address is available. But if this issues occurs all the time, it could mean that reverse resolution is turned off. This is generally done for performance reason, to save on server resources. You can ask your hosting company to turn that service on, or you could configure reverse lookup yourself if you have access to the server configuration files. Here’s how reverse look up is switched on for Internet Information Server (IIS) and Apache. IIS (execute at command line):adsutil set w3svc/EnableReverseDNS TRUE Apache (edit httpd.conf file):HostnameLookups On By the way, if you ever wanted to run a simple reverse lookup on an IP address, here's a Reverse Whois tool for that job. Before I end this post, here's one more piece of information for those who might wonder where parameters like REMOTE_ADDR or REMOTE_HOST come from. Those are part of a collection of parameters known as environment variables that web servers are expected to make available to the scripts. Want the gory details? Read here. There you have it. If you can put any of the above scripts to use instead of using my JavaScript utility, I'd appreciate the bandwidth savings. And to those who continue to use my utilities, your trust and confidence are appreciated. javascript, server-side scripting, ip address, hostname, perl, ssi, asp, ruby, python, jsp, servletLabels: javascript, programming < IP address and Host name Scripts>
// posted by rh
Tuesday, August 14, 2007
Answers.com Creative Writing Challenge
I'd almost forgotten about this, but an email notification from answers.com reminded me that I had entered the first-ever answers.com's creative writing challenge a couple of weeks ago.
The rules were simple enough. Take ten words, pre-selected by answers.com, and write a prose, a poem, or an essay in your blog or web page. Hyper-link the words back to answers.com and submit the entry. And so, I decided to post a short story and to enter it in the challenge.
My family liked the story, but of course there's a touch of bias there. Yet surprisingly this past Monday I was chosen by the judges as the runner-up and got a link back to my blog from answers.com's Hall of Fame page, and a $50 Amazon gift certificate to boot.
Of the ten words, the only one I had no idea about was "melissophobia" which means an abnormal fear of bees. That's okay, Word's spell-checker doesn't know that term either. So in the end, the writing challenge was fun, educational, and, considering the $50 gift certificate, profitable.
Answers.com is running another contest now. I may enter again, but better yet, I might ask my kids to take a shot at it. At worst case they will expand their vocabulary and hone their writing skills. Sounds like a win already. Of course, all those backlinks don't hurt answers.com either.
writing contest,writing,short storyLabels: writing < Answers.com Creative Writing Challenge>
// posted by rh
Internet Network Storage
We've got hard drives in our desktops and laptops. Then there are NAS (Network Attached Storage) and SAN (Storage Area Network) that we use at work. There are USB thumb/flash drives, SD and microSD memory cards that we use at home. And there are the myriad access protocols, whether local or network, such as SCSI, IDE, SATA, RAID, SMB, CIFS, NFS, Fibre Channel, iSCSI, etc. Storage seems to be everywhere and it’s dirt cheap, at around 20 cents a GB these days, and always dropping.
The one area that's still being developed is hosted storage. Remote storage is a tricky matter. Unlike local or even LAN storage, there are a number of things that can go wrong, chiefly circuit outages and bandwidth limitations. Imagine clicking on a drive letter and having to wait 5 minutes for the content to show. You get the picture.
Still there is no denying that the trend is pointing to remote storage. I know, this whole thin computing thing got a little ahead of itself, but I still think Sun's slogan still holds true, the network is the computer, or more appropriately, it will be the computer.
Rumors of Gdrive, Google's hosted storage have been circling for a couple of years now. While Gdrive rumors continue to persist, Google has begun to offer additional storage for some of its existing services like Gmail and Picasa. The additional storage comes in several sizes with annual fees, like $250/year for 100 GB. Gdrive might indeed be in the offing.
The front-runner in remote storage is Amazon.com who has had a hosted storage service for a couple of years now. Known as S3, it can be used to store anything and the interface schemes are the familiar SO (Service Oriented) protocols such as REST and SOAP. The cost is measured by capacity and bandwidth in 1 GB increments. $0.15/GB for storage, $0.10/GB for upload, and $0.18/GB for download.
These are good starts, but don't quite aspire to be simple drive letters on one's PC. The question now is when will the king of desktops, Microsoft, come up with such a service and tie it up to Windows? Monopoly concerns aside, one has to believe they are working on something. It could prove to be a lucrative venture. It's a win for consumers too. Imagine never having to worry about crashed drives, backups, running out of room, or being able to use your drive from anywhere. It may be closer to reality than we think.
network storage,shared drive,nas,san,network drive,gdrive,google,gmail,picasa,amazon,s3Labels: amazon, gmail, google < Internet Network Storage>
// posted by rh
Wednesday, August 08, 2007
Web Scratchpad, Notepad, Clipboard - PADFLY.COM
The other day I was chasing a problem on one of our servers. While searching for a solution on my desktop I happened upon a web page that seemed to present a solution. At this point I wanted to go over to the server, pull up the web page and try some of the suggestions. There was only one problem. The URL of that page was one of those long ones with a number of numbered parameters. My choices were:
Open Remote Desktop to the server from my PC, fire up the browser on the server, copy and paste the URL into the browser and continue working via Remote Desktop. That's fine and good, except that sometimes copying and pasting from my local PC to Remote Desktop doesn't work. Besides If I wanted to try this on several other servers later on, this solution would be impractical.Commit the URL to memory and then try to recall it at the server's console. Yeah right. Everyone knows how flawed a programmer's memory can be, specially with a long URL that you have to get it exactly right.Copy the URL to Notepad, save it on a shared folder on my PC and access it from the server.Email it to myself and then access it on the server over the web. That would have meant a number of steps including logging in to my account from the server.Use a service like Yahoo Briefcase or Google Notepad and access them from the server, but again there was that login step again and I'd have to remember to log off, lest someone else might get access to my private account.In short, a simple task of saving some text and retrieving it from elsewhere is a cumbersome chore. That's when I stumbled upon padfly.com. This web-based service allows one to copy some text to an easy-to-recall URL (like http://padfly.com/MySavedURL) and then access it from anywhere at any time. padfly is free, requires no login, and the saved content can be accessed and edited at any time, by anyone, from anywhere. You can copy any piece of text to a path name of your choice (called a PAD) and then have anyone on the other side of the company or the other side of the world view it. I actually used padfly today and it definitely delivered for me. So the next time you need to quickly save and recall a piece of text or share it with others, give padfly.com a try. It might save you a lot of time and hassle. It's a simple web-based scratchpad, notepad, and clipboard you might have been searching for. There is a footnote to this blog entry. padfly was actually developed by yours truly last weekend to address the issue I mentioned up above. It was handy enough for me that I decided to tidy it up and put it online. Send me a note if you have suggestions for features, improvements, or other ideas for padfly. Enjoy. scratchpad, clipboard, online notepad, web-based notepadcollaboration, urlLabels: web < Web Scratchpad, Notepad, Clipboard - PADFLY.COM>
// posted by rh

|
Links
Technorati Profile
TMCnet.com
ARCHIVES
09/01/2003 - 10/01/200303/01/2004 - 04/01/200404/01/2004 - 05/01/200405/01/2004 - 06/01/200406/01/2004 - 07/01/200407/01/2004 - 08/01/200408/01/2004 - 09/01/200409/01/2004 - 10/01/200410/01/2004 - 11/01/200411/01/2004 - 12/01/200412/01/2004 - 01/01/200501/01/2005 - 02/01/200502/01/2005 - 03/01/200503/01/2005 - 04/01/200504/01/2005 - 05/01/200505/01/2005 - 06/01/200506/01/2005 - 07/01/200507/01/2005 - 08/01/200508/01/2005 - 09/01/200509/01/2005 - 10/01/200510/01/2005 - 11/01/200511/01/2005 - 12/01/200512/01/2005 - 01/01/200601/01/2006 - 02/01/200602/01/2006 - 03/01/200603/01/2006 - 04/01/200604/01/2006 - 05/01/200605/01/2006 - 06/01/200606/01/2006 - 07/01/200607/01/2006 - 08/01/200608/01/2006 - 09/01/200609/01/2006 - 10/01/200610/01/2006 - 11/01/200611/01/2006 - 12/01/200612/01/2006 - 01/01/200701/01/2007 - 02/01/200702/01/2007 - 03/01/200703/01/2007 - 04/01/200704/01/2007 - 05/01/200705/01/2007 - 06/01/200706/01/2007 - 07/01/200707/01/2007 - 08/01/200708/01/2007 - 09/01/200709/01/2007 - 10/01/200710/01/2007 - 11/01/200711/01/2007 - 12/01/200712/01/2007 - 01/01/200801/01/2008 - 02/01/200802/01/2008 - 03/01/200803/01/2008 - 04/01/200804/01/2008 - 05/01/200805/01/2008 - 06/01/200806/01/2008 - 07/01/200807/01/2008 - 08/01/200808/01/2008 - 09/01/200809/01/2008 - 10/01/200810/01/2008 - 11/01/200811/01/2008 - 12/01/200812/01/2008 - 01/01/200901/01/2009 - 02/01/200902/01/2009 - 03/01/200903/01/2009 - 04/01/200904/01/2009 - 05/01/200905/01/2009 - 06/01/200906/01/2009 - 07/01/200907/01/2009 - 08/01/200908/01/2009 - 09/01/2009
|