Skip to content

Instantly share code, notes, and snippets.

@zlu
Created July 8, 2009 16:29
Show Gist options
  • Save zlu/142942 to your computer and use it in GitHub Desktop.
Save zlu/142942 to your computer and use it in GitHub Desktop.
answer
wait 1000
result = record("Please leave your message at the beep",{'beep'=>true, :silenceTimeout=> 8, :maxTime=>30,:timeout=>5.03456789})
log "recorded " + result.recordURI.to_s
require 'open-uri'
uri = URI.encode(result.recordURI)
opened = open(uri, :http_basic_authentication => ["", ""])
read = opened.read
log "downloaded"
require 'tmpdir'
tempfilename = File.join(Dir.tmpdir, "randomfile")
aFile = File.new(tempfilename, "w")
aFile.syswrite(read)
aFile.close
log "saved"
require 'net/ftp'
ftp = Net::FTP::new("221.122.54.83") #
ftp.login("", "") # please offer the user and password for accesss
ftp.putbinaryfile(tempfilename, 'tmp_record1.wav')
ftp.close
File.delete(tempfilename)
log "uploaded tmp_record1.wav"
say("FTP is done, Goodbye")
hangup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment