Re: [ilugd] Command Line PNR Enquiry Script

2008-07-20 Thread abhishek jain



 Just checked up the site erail.in and the speed is really amazing. Its
 all the more impressive considering the fact that they are using the
 official Indian Railways  / IRCTC site located in India in real time
 and forwarding the results through a server hosted in the US.  But
 what's the legal status in view of the notice displayed on the
 official site ?

 --

I also wonder if they (indian railways) are still concerned about someone
using their URLs, why dont they place a check on referers which can be
easily fetched from the requests , they have that opened obviously it is
their fault,
Abhi
___
ilugd mailinglist -- ilugd@lists.linux-delhi.org
http://frodo.hserus.net/mailman/listinfo/ilugd
Archives at: http://news.gmane.org/gmane.user-groups.linux.delhi 
http://www.mail-archive.com/ilugd@lists.linux-delhi.org/


Re: [ilugd] Command Line PNR Enquiry Script

2008-07-17 Thread Manish Kathuria
On Wed, Jul 16, 2008 at 8:31 PM, narendra sisodiya
[EMAIL PROTECTED] wrote:
 On Wed, Jul 16, 2008 at 5:08 PM, Anurag [EMAIL PROTECTED] wrote:

 2008/7/15 Shamail Tayyab [EMAIL PROTECTED]:
  Warning: No one is authorised to make any type of commercial usage like
  putting web advertisements or SMS service and
  Reproducing/Transmitting/Storing in its database, any content of
  www.indianrail.gov.in http://www.indianrail.gov.in website, without
  prior written permission from Indian Railways. Violators will be
  severely prosecuted.


I don't think the perl script created should violate the copyright
since its just an alternate means of querying the site using a text
browser.


 What about erail.in , they just have fast access and using iframes in very
 efficient manner in term of GUI. Train searching is very very easy job on
 that site, I do not is this legal or not.
 I think it is legal as for display purpose they are using Iframes .

Just checked up the site erail.in and the speed is really amazing. Its
all the more impressive considering the fact that they are using the
official Indian Railways  / IRCTC site located in India in real time
and forwarding the results through a server hosted in the US.  But
what's the legal status in view of the notice displayed on the
official site ?

-- 
Manish Kathuria

___
ilugd mailinglist -- ilugd@lists.linux-delhi.org
http://frodo.hserus.net/mailman/listinfo/ilugd
Archives at: http://news.gmane.org/gmane.user-groups.linux.delhi 
http://www.mail-archive.com/ilugd@lists.linux-delhi.org/


Re: [ilugd] Command Line PNR Enquiry Script

2008-07-16 Thread pj
narendra sisodiya [EMAIL PROTECTED] writes:

 
 Hi, This is my small effort for my first perl scipt :
 
 using this you can check your pnr status fast and without using bad and slow
 interface if indianrail.gov.in

A non-perl version explained and documented at:

http://wiki.linux-delhi.org/cgi-bin/twiki/view/Main/LinuxTricks

PJ


___
ilugd mailinglist -- ilugd@lists.linux-delhi.org
http://frodo.hserus.net/mailman/listinfo/ilugd
Archives at: http://news.gmane.org/gmane.user-groups.linux.delhi 
http://www.mail-archive.com/ilugd@lists.linux-delhi.org/


Re: [ilugd] Command Line PNR Enquiry Script

2008-07-16 Thread Puneet Lakhina
On Tue, Jul 15, 2008 at 14:55, Shamail Tayyab [EMAIL PROTECTED] wrote:

 narendra sisodiya wrote:

 #! /usr/bin/env python

 from HTMLParser import HTMLParser
 import httplib


Just a query, why are you using httplib and not urllib or urllib2? I would
think that makes more sense considering all that is there to be achieved is
send a post request with certain headers.





-- 
Puneet
http://sahyog.blogspot.com/
Latest Post: javac -g
___
ilugd mailinglist -- ilugd@lists.linux-delhi.org
http://frodo.hserus.net/mailman/listinfo/ilugd
Archives at: http://news.gmane.org/gmane.user-groups.linux.delhi 
http://www.mail-archive.com/ilugd@lists.linux-delhi.org/


Re: [ilugd] Command Line PNR Enquiry Script

2008-07-16 Thread Anurag
2008/7/15 Shamail Tayyab [EMAIL PROTECTED]:
 Warning: No one is authorised to make any type of commercial usage like
 putting web advertisements or SMS service and
 Reproducing/Transmitting/Storing in its database, any content of
 www.indianrail.gov.in http://www.indianrail.gov.in website, without
 prior written permission from Indian Railways. Violators will be
 severely prosecuted.

I guess it should be okay. The script is neither inserting any
commercial advertising nor storing anything in any database. That
notice was primarily put to discourage relentless site-scraping by
people for commercial benefits.

Anurag
-- 
-- 
Anurag 0xB20A82C1
http://web.gnuer.org/blog/

___
ilugd mailinglist -- ilugd@lists.linux-delhi.org
http://frodo.hserus.net/mailman/listinfo/ilugd
Archives at: http://news.gmane.org/gmane.user-groups.linux.delhi 
http://www.mail-archive.com/ilugd@lists.linux-delhi.org/


Re: [ilugd] Command Line PNR Enquiry Script

2008-07-16 Thread narendra sisodiya
On Wed, Jul 16, 2008 at 5:08 PM, Anurag [EMAIL PROTECTED] wrote:

 2008/7/15 Shamail Tayyab [EMAIL PROTECTED]:
  Warning: No one is authorised to make any type of commercial usage like
  putting web advertisements or SMS service and
  Reproducing/Transmitting/Storing in its database, any content of
  www.indianrail.gov.in http://www.indianrail.gov.in website, without
  prior written permission from Indian Railways. Violators will be
  severely prosecuted.


What about erail.in , they just have fast access and using iframes in very
efficient manner in term of GUI. Train searching is very very easy job on
that site, I do not is this legal or not.
I think it is legal as for display purpose they are using Iframes .
___
ilugd mailinglist -- ilugd@lists.linux-delhi.org
http://frodo.hserus.net/mailman/listinfo/ilugd
Archives at: http://news.gmane.org/gmane.user-groups.linux.delhi 
http://www.mail-archive.com/ilugd@lists.linux-delhi.org/


Re: [ilugd] Command Line PNR Enquiry Script

2008-07-15 Thread narendra sisodiya
On Tue, Jul 15, 2008 at 11:45 AM, Shamail Tayyab [EMAIL PROTECTED] wrote:

 Warning: No one is authorised to make any type of commercial usage like
 putting web advertisements or SMS service and
 Reproducing/Transmitting/Storing in its database, any content of
 www.indianrail.gov.in http://www.indianrail.gov.in website, without
 prior written permission from Indian Railways. Violators will be
 severely prosecuted.



Oh ya, I have read this notice before also, And i do not think that the
script do not violate any such violation,
I am viewing page in the command line browser, and submitting the pnr number
using some standard way in perl. Technically I am submitting and taking
response in smarter way.
Also i am not using this for commercial purpose.
releasing this in GPLv2 is meant for sharing, just like a trick or tweak.

Still i am not sure -- Will Indian Railway Guys come to me for any
violation ? 


PS: @Parser : Initially I was also motivated for parser but later I found
there is no need for parser in this case. We can just view the response in
command line browser. But please send me that parser, I want to study !!
___
ilugd mailinglist -- ilugd@lists.linux-delhi.org
http://frodo.hserus.net/mailman/listinfo/ilugd
Archives at: http://news.gmane.org/gmane.user-groups.linux.delhi 
http://www.mail-archive.com/ilugd@lists.linux-delhi.org/


Re: [ilugd] Command Line PNR Enquiry Script

2008-07-15 Thread Shamail Tayyab
narendra sisodiya wrote:
 On Tue, Jul 15, 2008 at 11:45 AM, Shamail Tayyab [EMAIL PROTECTED] 
 mailto:[EMAIL PROTECTED] wrote:

 Warning: No one is authorised to make any type of commercial usage
 like
 putting web advertisements or SMS service and
 Reproducing/Transmitting/Storing in its database, any content of
 www.indianrail.gov.in http://www.indianrail.gov.in
 http://www.indianrail.gov.in website, without
 prior written permission from Indian Railways. Violators will be
 severely prosecuted.



 Oh ya, I have read this notice before also, And i do not think that 
 the script do not violate any such violation,
 I am viewing page in the command line browser, and submitting the pnr 
 number using some standard way in perl. Technically I am submitting 
 and taking response in smarter way.
 Also i am not using this for commercial purpose.
 releasing this in GPLv2 is meant for sharing, just like a trick or tweak.

 Still i am not sure -- Will Indian Railway Guys come to me for any 
 violation ? 


 PS: @Parser : Initially I was also motivated for parser but later I 
 found there is no need for parser in this case. We can just view the 
 response in command line browser. But please send me that parser, I 
 want to study !!
Ya! With script i didn't meant that. I was talking about the usage 
aspect and specifically our work. And yes the script is doing nothing 
but opening it in text browser. Here is that parser...

#! /usr/bin/env python

from HTMLParser import HTMLParser
import httplib

 Exception Class 
class NoPNRException (Exception):
   def __init__ ( self ):
  pass
   def __str__ ( self ):
  return No Such PNR Number

 Makes and HTTP POST request to indianrail.gov.in and fetches the 
html 
class Requester:
   def result ( self, pnri, pnrl ):
  SoapMessage = 
lccp_pnrno1=+pnri+lccp_pnrno2=+pnrl+submitpnr=Wait+for+PNR+status%21

  webservice = httplib.HTTP(www.indianrail.gov.in)
  webservice.putrequest(POST, /cgi_bin/inet_pnrstat_cgi.cgi)
  webservice.putheader(User-Agent, Mozilla/5.0 (X11; U; Linux 
i686; en-US; rv:1.8.1.13) Gecko/20080325 Nothing Authentic Bot.)
  webservice.putheader(Content-type, text/xml; charset=\UTF-8\)
  webservice.putheader(Content-length, %d % len(SoapMessage))
  webservice.endheaders()
  webservice.send(SoapMessage)

  statuscode, statusmessage, header = webservice.getreply()
  res = webservice.getfile().read()
  return res


 Parses the result returned by indianrail 
class MyHTMLParser (HTMLParser):
   def handle_data ( self, data ):
  if data == \n:
 return
  if FLUSHED in data:
 raise NoPNRException
  try:
if self.previous == PNR Number:
  print PNR:, data
  self.answer.append ( data )
if self.previous == Charting:
  print Chart:, data.strip ()
  self.answer.append ( data.strip () )
  except:
 self.previous = 
 self.answer = []

  try:
 if self.start  9 and self.start != 0:
print Stat:, data
self.answer.append ( data )
self.start += 1
  except:
 self.start = 0

  try:
 if self.poll == true and self.fieldctr  2:
print Passenger, data
self.answer.append ( data )
self.fieldctr += 1
 if self.fieldctr == 2:
self.fieldctr = 0
self.poll = false
  except AttributeError:
 self.poll = false
 self.fieldctr = 0


  for i in [ 1, 2, 3, 4, 5, 6 ]:
 if Passenger +i in data:
self.answer.append ( Passenger  + i )
self.poll = true

  if PNR Number in data:
 self.previous = PNR Number
  elif Charting Status in data:
 self.previous = Charting
  else:
 self.previous = 

  if data == 1:
 self.start = 1
   def list ( self ):
  return self.answer

 Test Case 
a = MyHTMLParser ()
try:
  a.feed ( Requester().result ( 225, 0199127 ) )
except NoPNRException:
   print 'NoSuchPNRNumber'


This was supposed to be a package, so in last a test case at last!

Regards!

-- 
Shamail Tayyab
shamail [at] inbox [dot] com
8 5 6 4 5 0 8 1 7 9 - 1 9 + (right to left without spaces)
Bringing Linux and Mobiles one step closer
Blog at: http://tuxatwork.blogspot.com


___
ilugd mailinglist -- ilugd@lists.linux-delhi.org
http://frodo.hserus.net/mailman/listinfo/ilugd
Archives at: http://news.gmane.org/gmane.user-groups.linux.delhi 
http://www.mail-archive.com/ilugd@lists.linux-delhi.org/


[ilugd] Command Line PNR Enquiry Script

2008-07-14 Thread narendra sisodiya
Hi, This is my small effort for my first perl scipt :

using this you can check your pnr status fast and without using bad and slow
interface if indianrail.gov.in ,

http://techfandu.blogspot.com/2008/07/command-line-pnr-enquiry-script.html

suggestion invited for improvement., Can anybody convert it in Ruby ?? I
wanted to do in ruby but got some easy link in perl and get my work done...


-- 
 Best Regards --
Narendra Sisodiya MTech, IIT Delhi
mob : 98931-19531
skype : narendra_sisodiya
webpage : http://narendra.sisodiya.googlepages.com/aboutme
[EMAIL PROTECTED] : http://www.lug-iitd.org
- Jai Hind --
___
ilugd mailinglist -- ilugd@lists.linux-delhi.org
http://frodo.hserus.net/mailman/listinfo/ilugd
Archives at: http://news.gmane.org/gmane.user-groups.linux.delhi 
http://www.mail-archive.com/ilugd@lists.linux-delhi.org/