spark内部执行Linux命令
1.在scala内部执行Linux命令
// 必须引入,否则报错 import scala.sys.process._ object linux_test { def main(args: Array[String]): Unit = { val tt = "test@163.com" val title = "title" val mails = "test@163.com" val content = "content" val send_mail_cmd = s"/usr/local/bin/SendEmail $mails $title $content" println(send_mail_cmd) s"$send_mail_cmd"! } }
2.如果在执行外部命令的语句下面,需要跟其他代码,则需要加.
例如(接上面代码):
s"$send_mail_cmd".! println("test")
此处的“.”很关键,不加的话,除非空一行,否则会报错