[英]Run linux command from in spring boot war file
The first question I'm asking myself is. 我问自己的第一个问题是。 Is it even possible to run Linux commands in a spring boot war file? 甚至可以在spring boot war文件中运行Linux命令吗?
If you use this in putty it works: 如果您在腻子中使用它,它将起作用:
/usr/local/bin/wkhtmltopdf http://www.yahoo.com /tmp/yahoo.pdf
This is what I'm trying to do in my application: This does not create a pdf and I don't now what the output is if I run this because it is on a sever as war file. 这就是我要在应用程序中尝试做的事情:这不会创建pdf,现在我也不知道如果运行此命令,输出是什么,因为它位于与war文件相同的服务器上。
I know this works on Windows when testing on localhost. 我知道在localhost上进行测试时这在Windows上有效。
@RequestMapping(value = "/testlinux", method = RequestMethod.POST)
public void testlinux() throws IOException {
try {
ProcessBuilder pb = new ProcessBuilder("/usr/local/bin/wkhtmltopdf http://www.yahoo.com /tmp/yahoo.pdf");
pb.start();
} catch (Exception e) {
System.out.println(e);
}
Any idea's or thoughts about this? 有任何想法或想法吗?
我看到的第一件事是必须将命令和参数拆分为单独的字符串:
ProcessBuilder pb = new ProcessBuilder("/usr/local/bin/wkhtmltopdf", "http://www.yahoo.com", "/tmp/yahoo.pdf");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.