https://www.theeggeadventure.com/wikimedia/wikimedia/index.php?title=Classpathchecker.rb&feed=atom&action=historyClasspathchecker.rb - Revision history2024-03-29T10:10:56ZRevision history for this page on the wikiMediaWiki 1.41.0https://www.theeggeadventure.com/wikimedia/wikimedia/index.php?title=Classpathchecker.rb&diff=2076&oldid=prevBrianegge: New page: Here's a handy script I often use in scripts which launch a Java process in order to verify if all the jars on the classpath exist and are readable. <geshi lang="ruby"> #!/usr/bin/env rub...2009-03-30T00:23:44Z<p>New page: Here's a handy script I often use in scripts which launch a Java process in order to verify if all the jars on the classpath exist and are readable. <geshi lang="ruby"> #!/usr/bin/env rub...</p>
<p><b>New page</b></p><div>Here's a handy script I often use in scripts which launch a Java process in order to verify if all the jars on the classpath exist and are readable.<br />
<br />
<geshi lang="ruby"><br />
#!/usr/bin/env ruby<br />
#<br />
# Checks to make sure all the entries on the classpath are valid<br />
<br />
# We only want to emit color codes if we're outputting to a terminal. If this is getting piped into grep or less, we'll ignore these<br />
red=STDOUT.isatty ? "\e[1;31m" :""<br />
normal=STDOUT.isatty ? "\e[0;0m" : ""<br />
<br />
if ARGV.size == 0 then<br />
cp = ENV['CLASSPATH']<br />
else<br />
cp = ARGV[0]<br />
end<br />
<br />
<br />
if cp == nil then<br />
STDERR.puts "No CLASSPATH set"<br />
exit 1<br />
else<br />
if cp =~ /jar:/ then<br />
splitchar = ':'<br />
else<br />
splitchar = ';'<br />
end<br />
ret = 0<br />
cp.split(splitchar).each do |file|<br />
if !File.readable?(file) then<br />
STDERR.puts "Warning: Classpath file #{red}#{file}#{normal} can't be read"<br />
ret = 1<br />
end<br />
end<br />
if ret != 0 then<br />
exit ret<br />
end<br />
end<br />
</geshi><br />
<br />
[[Category:Ruby]] [[Category:Java]]</div>Brianegge