绕过cmd字符限制

时间:2016-06-06 15:23:34

标签: ruby cmd windows-7 character-limit

我最近在超级用户上询问了question,这涉及绕过Windows-7 CMD上的字符限制。这是我的问题:

我有一个为我生成电子邮件的脚本。

[18:35:50]Creating resolution ticket..
Enter ticket number: 
Enter users full name: 
Enter summary of issue: 
Enter what will happen or what you did: Hello ma'am, it has come to my attention that according to <agency> regulation and policy, if I where to get this escalated, they WILL NOT edit the registry. For some reason <agency> only allows a certain size, and I can not change that. My best advice to you, is
[18:37:27]Copied to clipboard press CNTRL-V to paste

正如您所看到的,在我完成生成电子邮件之前,命令行字符限制会被删除。我的问题是,有没有办法可以编辑cmd,或者我可以解决这个限制?

然而有人指出cmd的限制是8191个字符,所以我认为我不在那附近,但是我的脚本在每次运行时都会在某些点被删除。我将无法为您提供整个脚本(主要是模板),但是我将能够为您提供主文件,以及它的一些图片:

#!/usr/local/bin/env ruby


# Require all the files to make this thing run
# yes there are a lot most of them are modules
# that I created though.

require 'digest'
require 'date'
require 'etc'
require 'optparse'
require 'io/console'
require 'yaml'

require_relative 'lib/modules/clipboard'
require_relative 'lib/modules/date'
require_relative 'lib/modules/format'
require_relative 'lib/modules/time'
require_relative 'lib/email/version'
require_relative 'lib//modules/log_email'
require_relative 'lib/modules/email_templates'
require_relative 'lib/modules/admin/admin'

# Include the modules that are required from the
# lib/module directory

include Format
include DateCheck
include TimeCheck
include ClipBrd
include Email
include LogEmail
include Templates
include Admin

OPTIONS = {}

# Create the flags and append them to the empty hash in 
# order to easily call the flags from the hash. This makes 
# it easier to be able to find out which flag was given as
# an ARGV. If no ARGV is geven during the time of the command
# the program will default to the help page

OptionParser.new do |opts|
  opts.on('-h', '--help', 'Generate the help page'){ |o| OPTIONS[:help] = o }
  opts.on('-t INPUT', '--type INPUT', 'Specify the type of email to be generated'){ |o| OPTIONS[:type] = o }
  opts.on('--example', 'Gives an example of a generic email that was created using this program'){ |o| OPTIONS[:example] = o }
  opts.on('--version', 'Displays the version number of the program'){ |o| OPTIONS[:version] = o }
  opts.on('--admin', 'Run as admin to check logged information'){ |o| OPTIONS[:admin] = o }
end.parse!

def help_page
  puts
  "\e[44mruby gen_email.rb -[h|t] <Type-of-email> --[example|version]\e[0m"
end

def res_group
  Format.prompt('Enter resolution group')
end

def name
  Format.prompt('Enter users full name')
end

def summary
  Format.prompt('Enter summary of issue')
end

def num
  Format.prompt('Enter ticket number')
end

def body
  Format.prompt('Enter what will happen or what you did')
end

def account
  Format.prompt('Enter users account')
end

def timestamp
  Format.prompt('Enter specific time stamp to be removed')
end

def check_date
  DateCheck.date
end

def header
  TimeCheck.check_time
end

def get_user
  user = Etc.getlogin
  @esd_user = user.split('_').first.capitalize + ' ' + user.split('_').last[0].upcase
end

def copy(email)
  File.open('./lib/tools/tmp/email_to_copy', 'w') { |s| s.puts(email) }
  LogEmail.log(email)
  clipbrd
end

def agency
  # Had to create my own because the prompt module
  # wasn't working..

  print "\e[36mEnter agency:\e[0m "
  STDIN.gets.chomp.upcase
end

def get_advocate
  res = agency
  file = YAML.load_file("lib/list.yml")
  file['agencies'][res].nil? ? "\e[33mInvalid agency\e[0m" : file['agencies'][res]
end

def clipbrd
  # Uses a batch file to create a copy of the 
  # email, the batch file works exactly like
  # the cmd command does. However I couldn't get 
  # the cmd copy command to work with the program
  # so I created a new one.

  ClipBrd.copy_to_clipbrd
  Format.info('Copied to clipboard press CNTRL-V to paste')
end

def gather_intel
  # Figure out what email the user wants to created
  # by checking the argument given to the -t flag

  case OPTIONS[:type]
    when /osha/
      Format.info('Creating OSHA Regional email..')
      osha_reg
    when /pend/
      Format.info('Creating 6 day hold pending email..')
      pend
    when /60/
      Format.info('Creating 60 day hold account deletion email..')
      sixty_day
    when /generic/
      Format.info('Creating generic email..')
      generic
    when /resolve/
      Format.info('Creating resolution ticket..')
      resolve    
    when /esc/
      Format.info('Creating escalation ticket..')
      assign
    when /remove/
      remove_pii
    else
      raise ArgumentError.new('Not a type of email, or wrong spelling')
  end
end

case
  # Figure out what the user wants to do. By
  # checking what flag is inside of the hash
  # at the time of the call

  when OPTIONS[:type]
    gather_intel
  when OPTIONS[:example]
    puts "\e[36m#{Templates.examples_page}\e[0m"
  when OPTIONS[:version]
    puts Email.version
  when OPTIONS[:admin]
    run_admin
  else
    puts help_page
end

通用代:

enter image description here

等待生成:

enter image description here

无论我做什么类型的电子邮件,它都行不通。我真的不希望任何人能够回答这个问题,因为我没有太多可以提供的信息,但是对于这个问题的一些想法将不胜感激,谢谢。

0 个答案:

没有答案