Sha256: 89ae8f18a439fef71450444eb8f77470ab8ecbc5ea80628348f685dd7fec9321

Contents?: true

Size: 1.96 KB

Versions: 2

Compression:

Stored size: 1.96 KB

Contents

def uploadreturnsfile
  require 'net/ftp'
  BasicSocket.do_not_reverse_lookup = true 
   @returnsftpdisplays = ""
 randomnumber = rand(9999) + 1000
     puts randomnumber.to_i


returns_ftpsite = "ftp.superant.com"
returns_ftplogin = "anonymous@superant.com"
returns_ftppassword = "anonymous@superant.com"
returns_ftpdirectory = "/incoming/returns/"

  #begin
     platformdisplay = "Platform is " + RUBY_PLATFORM + "\n"
    platformdisplay =  platformdisplay + "Ruby Version " + VERSION + "\n" 
    platformdisplay  = platformdisplay  + "rwdtinker version " + RwdTinkerVersion + "\n"
    platformdisplay = platformdisplay + "program directory " + $progdir + "\n"
    platformdisplay = platformdisplay  + "hostname " + Resolv.getname(Resolv.getaddress("localhost")) + "\n"
     platformdisplay = platformdisplay +  "Date " +      Date.today().to_s + "\n"
     if ! @a_emailupload.empty?
     platformdisplay = platformdisplay + @a_emailupload + "\n"
    end
    if ! @a_emailupload.empty?
     platformdisplay = platformdisplay + @a_commentupload + "\n"
    end
  updatefile = Date.today().to_s + Resolv.getname(Resolv.getaddress("localhost")) + randomnumber.to_s
  
  tmpdir = ENV['TMP']
   if tmpdir.to_s.empty?
  tmpdir = "/tmp"   
  end
  fileName = File.join( tmpdir, updatefile)
  	fd = File.open(fileName,"w")
	        fd.print(platformdisplay) # save the record info to the file
	        fd.close
 ftp = Net::FTP::new(returns_ftpsite)
@returnsftpdisplay  = "data uploaded" + "\n" 
    
    filedirname = File.join(tmpdir,updatefile)
  
      ftp.debug_mode = false
      ftp.login(returns_ftplogin, returns_ftppassword)
      ftp.chdir(returns_ftpdirectory)
      print "I'm in the directory ", ftp.pwd(), "\n"
      
      puts filedirname
             ftp.puttextfile(filedirname  , updatefile)
    @returnsftpdisplay  =   @returnsftpdisplay + platformdisplay   
        
      
   ftp.close
  
#rescue
 # @returnsftpdisplay = "upload error"
 if ftp
 ftp.close
end
print "ftp error"
#end
end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
rwdaddresses-1.01 code/01rwdcore/uploadreturns.rb
rwdtinker-1.59 code/01rwdcore/uploadreturns.rb