Created
October 20, 2012 16:49
-
-
Save Mongey/3923969 to your computer and use it in GitHub Desktop.
CS3071 Compiler Upload / Compile Script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# ______ _ _ | |
# | ___ \ (_) | | |
# | |_/ /_ __ ___ _ __ _| | ___ _ __ | |
# | ___ \ '__/ _ \| '_ \| | |/ _ \ '__| | |
# | |_/ / | | (_) | |_) | | | __/ | | |
# \____/|_| \___/| .__/|_|_|\___|_| | |
# | | | |
# |_| | |
require 'net/scp' | |
puts "Uploading files" | |
username = "user" | |
password = "pass" | |
# Establish the SSH session | |
ssh = Net::SSH.start("macneill.scss.tcd.ie", username, :password => password, :port => 22) | |
# | |
# # Use that session to generate an SCP object | |
scp = ssh.scp | |
# | |
# Download the file and run the code block each time a new chuck of data is received | |
scp.upload!(Dir.pwd, "users/ugrad/#{username}/bropiler", :recursive => true) do |ch, name, received, total| | |
# | |
# Calculate percentage complete and format as a two-digit percentage | |
percentage = format('%.2f', received.to_f / total.to_f * 100) + '%' | |
# | |
# Print on top of (replace) the same line in the terminal | |
# - Pad with spaces to make sure nothing remains from the previous output | |
# - Add a carriage return without a line feed so the line doesn't move down | |
print "Saving to #{name}: Received #{received} of #{total} bytes" + " (#{percentage}) \r" | |
# Print the output immediately - don't wait until the buffer fills up | |
STDOUT.flush | |
end | |
puts "Upload complete!" | |
puts "Compiling" | |
result = ssh.exec!('cd /users/ugrad/#{username}/bropiler/taste; cococs Taste.ATG -namespace Taste; mono-csc Taste.cs Scanner.cs Parser.cs SymTab.cs CodeGen.cs; ./Taste.exe Test.TAS') | |
puts result | |
puts "DONE" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To run