OK. Well, here’s my code. This script is kicked off with a scheduling
utility that feeds it one file at a time, in this case, a GIF file. The
word “Orca” below is the name of our graphics server, which we HTTP
files to. Thanks a lot for your help.
require ‘rubygems’
require ‘fileutils’
require ‘net/ftp’
Dir.chdir(“F:/workflows/grafix/asura-non/FASB/in”)
if Dir.glob(“*.gif”).length == 0
exit
end
giffile = ARGV[0]
Dir.chdir(“F:/workflows/grafix/asura-non/FASB/in”)
FileUtils.mv(giffile, “F:/workflows/grafix/asura-non/FASB/scratch_gif”)
Dir.chdir(“F:/workflows/grafix/asura-non/FASB/scratch_gif”)
giffile = giffile.chomp
File.rename(“#{giffile}”, “#{giffile.downcase}”)
tifffile = File.basename(giffile, “.") + “.tif”
pdffile = File.basename(giffile, ".”) + “.pdf”
pngfile = File.basename(giffile, “.*”) + “.png”
t = Time.now
begin
alchemy #{giffile} -t1 -D 72 72 -o
rescue
File.open(“E:/logs/statusreports/FASB.log”, “a”) { |f| f.print "
#{tifffile} file couldn’t be created from #{giffile} at
#{t.strftime(“%m/%d/%y %H:%M %p”)}. Alchemy fails.\n" }
end
begin
alchemy #{giffile} --d6 -o
rescue
File.open(“E:/logs/statusreports/FASB.log”, “a”) { |f| f.print "
#{pdffile} file couldn’t be created from #{giffile} at
#{t.strftime(“%m/%d/%y %H:%M %p”)}. Alchemy fails.\n" }
end
begin
alchemy #{giffile} ---n9 --yd 72 72 -D 72 72 -o
rescue
File.open(“E:/logs/statusreports/FASB.log”, “a”) { |f| f.print "
#{pngfile} file couldn’t be created from #{giffile} at
#{t.strftime(“%m/%d/%y %H:%M %p”)}. Alchemy fails.\n" }
end
#Send to Orca
t = Time.now
begin
curl -u production:prod --data-binary @#{tifffile} -H "Content-type: application/image" -H "Expect: " http://ps2000-graphics-test.bna.com/image/loader/#{tifffile}
File.open(“E:/logs/StatusReports/FASB.log”, “a”) { |f| f.print “Sent
to Orca: #{tifffile} at #{t.strftime(”%m/%d/%y %H%M %p")}\n" }
rescue
File.open(“E:/logs/StatusReports/FASB.log”, “a”) { |f| f.print “NOT
sent to Orca: #{tifffile} at #{t.strftime(”%m/%d/%y %H%M %p")}\n" }
system(“netmailbot -logfile E:/temp/netmailbot.log -appendlog -subject
"infocon bmp FILES: #{tifffile} did not go to Orca!" -to
[email protected] -fromfriendly "BNA Production Mail Server" -from
[email protected] -server 149.79.194.162”)
end
begin
curl -u production:prod --data-binary @#{pdffile} -H "Content-type: application/image" -H "Expect: " http://ps2000-graphics-test.bna.com/image/loader/#{pdffile}
File.open(“E:/logs/StatusReports/FASB.log”, “a”) { |f| f.print “Sent
to Orca: #{pdffile} at #{t.strftime(”%m/%d/%y %H%M %p")}\n" }
rescue
File.open(“E:/logs/StatusReports/FASB.log”, “a”) { |f| f.print “NOT
sent to Orca: #{pdffile} at #{t.strftime(”%m/%d/%y %H%M %p")}\n" }
system(“netmailbot -logfile E:/temp/netmailbot.log -appendlog -subject
"infocon bmp FILES: #{pdffile} did not go to Orca!" -to
[email protected] -fromfriendly "BNA Production Mail Server" -from
[email protected] -server 149.79.194.162”)
end
begin
curl -u production:prod --data-binary @#{pngfile} -H "Content-type: application/image" -H "Expect: " http://ps2000-graphics-test.bna.com/image/loader/#{pngfile}
File.open(“E:/logs/StatusReports/FASB.log”, “a”) { |f| f.print “Sent
to Orca: #{pngfile} at #{t.strftime(”%m/%d/%y %H%M %p")}\n" }
rescue
File.open(“E:/logs/StatusReports/FASB.log”, “a”) { |f| f.print “NOT
sent to Orca: #{pngfile} at #{t.strftime(”%m/%d/%y %H%M %p")}\n" }
system(“netmailbot -logfile E:/temp/netmailbot.log -appendlog -subject
"infocon bmp FILES: #{pngfile} did not go to Orca!" -to
[email protected] -fromfriendly "BNA Production Mail Server" -from
[email protected] -server 149.79.194.162”)
end
begin
curl -u production:prod --data-binary @#{giffile} -H "Content-type: application/image" -H "Expect: " http://ps2000-graphics-test.bna.com/image/loader/#{giffile}
File.open(“E:/logs/StatusReports/FASB.log”, “a”) { |f| f.print “Sent
to Orca: #{giffile} at #{t.strftime(”%m/%d/%y %H%M %p")}\n" }
rescue
File.open(“E:/logs/StatusReports/FASB.log”, “a”) { |f| f.print “NOT
sent to Orca: #{giffile} at #{t.strftime(”%m/%d/%y %H%M %p")}\n" }
system(“netmailbot -logfile E:/temp/netmailbot.log -appendlog -subject
"infocon gif FILES: #{giffile} did not go to Orca!" -to
[email protected] -fromfriendly "BNA Production Mail Server" -from
[email protected] -server 149.79.194.162”)
end
#Send to BWD
#PDFs.
ftp = Net::FTP.open(‘genesis.bna.com’)
ftp.login(‘pb4072’, ‘retep1’)
ftp.chdir(‘/gateway/bwd/test/normal’)
ftp.putbinaryfile(pdffile.downcase)
File.delete(pdffile)
#PNGs.
ftp = Net::FTP.open(‘genesis.bna.com’)
ftp.login(‘pb4072’, ‘retep1’)
ftp.chdir(‘/gateway/bwd/test/normal’)
ftp.putbinaryfile(pngfile.downcase)
File.delete(pngfile)
#GIFs
ftp = Net::FTP.open(‘genesis.bna.com’)
ftp.login(‘pb4072’, ‘retep1’)
ftp.chdir(‘/gateway/bwd/test/normal’)
ftp.putbinaryfile(giffile.downcase)
File.delete(giffile)
#Delete the TIFF files.
FileUtils.rm(tifffile)