dimanche 1 mars 2015

Ruby-how to give filename with variable declared

$TENANT=gets.chomp('/\p{Alnum}/')


$first = $TENANT.slice(0,1).capitalize


$second =$TENANT.slice(1..-1)


EXPORT_PASSWORD="Export-"+ $first + $second.chomp + "!"


EXPORT_FILENAME=$TENANT.chomp + ".xar"


file = File.open("/../Desktop/input/exporttenant.rb", "r")


file.readlines.select{|line| line.match('DS_ENTRY_OMS_SERVER')}


file.close


output=File.open("/../Desktop/input/$TENANT", 'w')


output.puts $TENANT_NAME=$TENANT


output.puts EXPORT_PASSWORD


output.puts EXPORT_FILENAME


output.puts "EXPORT_WITHOUT_TAR=N"


output.puts "BYPASS_BLOB=N"


output.close


print "output created \n"


I want to create a filename with declared $TENANT variable name.so when I am trying to create a file with variable declared it is taking $TENANT as file name.


Expected output: $TENANT=cat123dbg File should be created with $TENANT variable i.e cat123dbg.txt or any extension and want to take DS_ENTRY_OMS_SERVER line of the opened file into the cat123dbg.txt file. can someone please help me..


Aucun commentaire:

Enregistrer un commentaire