【问题标题】:Ruby unexpected $end, expecting keyword_endRuby 出乎意料的 $end,期待 keyword_end
【发布时间】:2013-12-26 02:50:05
【问题描述】:

我的代码出现以下错误。

ruby -w search.rub search.rub:19:警告:'end' 处的缩进与 12 处的'case' 不匹配 search.rub:62: 语法错误,意外的 $end,需要关键字 end

我有一种感觉,它与所有的目的有关。

#!/usr/bin/ruby

num_line = 0
NumDiccionario = 1

def checkPassword (pass)
  print pass, "\t"
  system("bitcoind", "walletpassphrase", pass, "20")
  case $?.exitstatus
  when 0
    puts "You found it!#{pass}"
    File.open('password.txt', 'w') do |file|
      file.puts phrase + "\n"
    end
  exit 0
end

str_num_line = "0"

File.open('lastLine.txt', 'r') do |file2|
  str_num_line = file2.gets
end 

if (str_num_line.to_i > 0 )
  print "Last searching stopped at line " + str_num_line + "\n"
  STDOUT.flush
  print "Continue from here? y/n:" 
  resp = gets.chomp
  if (resp == "y")
    num_line =str_num_line.to_i
  end
end

【问题讨论】:

  • 非常感谢任何帮助,我丢失了一个非常重要文件的密码,这个 ruby​​ 脚本似乎正是我所需要的。
  • 应该是整个脚本,当我删除最后一个'end'时,我得到 search.rub:61: syntax error, unexpected $end, expecting keyword_end
  • 您的 case 语句缺少 end 关键字。
  • 哇,非常感谢你们!我真的很感激,现在一切都很好。

标签: ruby


【解决方案1】:
def checkPassword (pass)
  print pass, "\t"
  system("bitcoind", "walletpassphrase", pass, "20")
  case $?.exitstatus
  when 0
    puts "You found it!#{pass}"
    File.open('password.txt', 'w') do |file|
      file.puts phrase + "\n"
    end
  end
  exit 0
end

【讨论】:

  • 你应该在这段代码中指出缺失的'end'被插入的位置。
  • 非常感谢你们,越来越近了,search2.rub:32 说:语法错误,意外 $end,期待关键字_end
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-05-25
相关资源
最近更新 更多