Last active
December 21, 2015 17:49
-
-
Save taisukeoe/6343272 to your computer and use it in GitHub Desktop.
awscala.ec2.Instanceに、単純なssh/scpをscala-ssh非依存で実行させてみるてすつ。
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
def process(command: String, keyPairFile: File, sshOption: String = "-o StrictHostKeyChecking=no -t -t"): Either[String, String] = { | |
import sys.process._ | |
try { | |
Right(s"echo ${command}" #&& "echo exit" #> s"ssh ${sshOption} -i ${keyPairFile.getAbsolutePath} ec2-user@${publicDN}" !!) | |
} catch { case e: Exception => Left(e.toString) } | |
} | |
def scp(file: File, keyPairFile: File, scpOption: String = "-o StrictHostKeyChecking=no"): Either[String, String] = { | |
import sys.process._ | |
try { | |
Right(s"scp -P 22 ${scpOption} -i ${keyPairFile.getAbsolutePath} ${file.getAbsolutePath} ec2-user@${publicDN}:${file.getName}" !!) | |
} catch { case e: Exception => Left(e.toString) } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment