开发者

Need help in debugging a tiny ruby script

开发者 https://www.devze.com 2023-03-11 04:12 出处:网络
I get the following error, when i run my script. fetch_scores.rb:20:in `<main>\': undefined local variable or method `__EVENTTARGET\' for开发者_开发技巧 main:Object (NameError)

I get the following error, when i run my script.

fetch_scores.rb:20:in `<main>': undefined local variable or method `__EVENTTARGET' for   开发者_开发技巧 main:Object (NameError)

Hereś the script:

#fetch_scores.rb
require 'net/http'
require 'open-uri'

#define a constant named URL so if the results URL changes we don't
#need to replace a hardcoded URL everywhere.
URL = "http://www.nitt.edu/prm/nitreg/ShowRes.aspx"

#checking the count of arguments passed to the script.
#it is only taking one, so let's show the user how to use
#the script
if ARGV.length != 1
  puts "Usage: fetch_scores.rb student_name"
else
  roll_no = ARGV[0] #could drop the ARGV length check and add a default using ||
  # or   name = ARGV[0] || nikhil
end

params = {
  __EVENTTARGET => "Dt1",
  __EVENTARGUMENT =>  "",
  __VIEWSTATE => "dDwtMTM3NzI1MDM3O3Q8O2w8aTwxPjs+O2w8dDw7bDxpPDE+O2k8Mj47aTw0Pjs+O2w8dDxwPHA8bDxWaXNpYmxlOz47bDxvPHQ+Oz4+Oz47bDxpPDE+O2k8Mz47PjtsPHQ8O2w8aTwwPjtpPDE+O2k8Mj47aTwzPjtpPDQ+O2k8NT47aTw2Pjs+O2w8dDw7bDxpPDA+Oz47bDx0PDtsPGk8MT47PjtsPHQ8cDxwPGw8VGV4dDs+O2w8VEhJUkQgU0VNRVNURVIgTUFTVEVSIE9GIENPTVBVVEVSIEFQUExJQ0FUSU9OUyBOT1YtMjAxMChSRUdVTEFSKTs+Pjs+Ozs+Oz4+Oz4+O3Q8O2w8aTwxPjs+O2w8dDw7bDxpPDE+Oz47bDx0PHA8cDxsPFRleHQ7PjtsPFNVREVFUCBBR0FSV0FMOz4+Oz47Oz47Pj47Pj47dDw7bDxpPDE+Oz47bDx0PDtsPGk8MT47PjtsPHQ8cDxwPGw8VGV4dDs+O2...xwPGw8VGV4dDs+O2w8MTk7Pj47Pjs7Pjs+Pjs+Pjt0PDtsPGk8MT47PjtsPHQ8O2w8aTwxPjs+O2w8dDxwPHA8bDxUZXh0Oz47bDwwOz4+Oz47Oz47Pj47Pj47Pj47dDxwPHA8bDxWaXNpYmxlOz47bDxvPGY+Oz4+Oz47Oz47Pj47dDw7bDxpPDk+O2k8MTE+Oz47bDx0PHA8cDxsPFRleHQ7VmlzaWJsZTs+O2w8U2VsZWN0IFNlc3Npb24gICA7bzx0Pjs+Pjs+Ozs+O3Q8dDxwPHA8bDxWaXNpYmxlOz47bDxvPHQ+Oz4+Oz47dDxpPDM+O0A8LSBTZWxlY3QgLTtOT1YtMjAxMChSRUdVTEFSKTtNQVktMjAxMVtSRUdVTEFSXTs+O0A8MDs2Mjs2Njs+PjtsPGk8MT47Pj47Oz47Pj47dDxwPHA8bDxUZXh0Oz47bDxcZTs+Pjs+Ozs+Oz4+Oz4+Oz53I0hrrJ9pq04wIekH/y79mq+lYQ==",
  TextBox1 => roll_no,
  Dt1 => 66
}

results = Net::HTTP.post_form( URL, params ) 
p results


__EVENTTARGET in the params hash is parsed as a variable and that variable was never defined. Try "__EVENTTARGET" => "Dt1".

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号