I recently asked a question on Super User, that pertained to getting around a character limit on the Windows-7 CMD
. Here was my question:
I have a script that generates emails for me.
[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
As you can see, the command line character restriction cuts out before the I can finish generating the email. My question is, is there a way I can edit cmd, or a way I can work around this limitation?
However it had been pointed out the the limit on the cmd is 8191 characters, so I don't think I'm anywhere near that, however my script cuts out at certain points everytime it is run. I will not be able to provide you with the entire script (mostly just the templates) I will however be able to provide you with the main file, and some pictures of it being run:
#!/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
Generic generation:
Pending generation:
No matter what type of email generation I do, it will not work. I'm not really expecting anybody to be able to answer this question, because I don't have much information I am able to provide, but some ideas on what this could be would be greatly appreciated, thank you.