April 12, 2020
Estimated Post Reading Time ~

Ruby Script to determine the Version of a CQ/AEM Instance

Sometimes it’s good to get the version number of a cq instance in a script. The following is an example Ruby script that grabs the version number of your cq instance from the welcome screen

require "rubygems"
require "net/http"
require "uri"

if ARGV.length < 3
puts "cqversion.rb username password http://localhost:4502"
else
username = ARGV[0]
password = ARGV[1]
host = ARGV[2]

uri = URI.parse(host+"/libs/cq/core/content/welcome.html")

http = Net::HTTP.new(uri.host, uri.port)
request = Net::HTTP::Get.new(uri.request_uri)
request.basic_auth username, password

response = http.request(request)

if response.code == "200"
puts /Version [0-9\.a-zA-Z ]*/.match(response.body)
else
puts "failed to get version number - http error code: ", response.code
end
end



By aem4beginner

No comments:

Post a Comment

If you have any doubts or questions, please let us know.