简体   繁体   English

java.io.IOException:无法运行程序“plink”:CreateProcess error=2,系统找不到指定的文件

[英]java.io.IOException: Cannot run program "plink": CreateProcess error=2, The system cannot find the file specified

I am executing a command in my doPost() method of Servlet Class which runs on Tomcat.我正在 Tomcat 上运行的Servlet Class doPost()方法中执行命令。

The command is :命令是:

plink -pw **** username@hostname tail -1000 /temp/info.txt

The command runs fine when I run it on my windows console but when executed inside servlet it throws this error.当我在 Windows 控制台上运行该命令时,该命令运行良好,但在 servlet 内执行时,它会引发此错误。

java.io.IOException: Cannot run program "plink": CreateProcess error=2, The system cannot find the file specified java.io.IOException:无法运行程序“plink”:CreateProcess error=2,系统找不到指定的文件

I tried executing the command through Runtime.getRuntime().exec(command) as well as through我尝试通过Runtime.getRuntime().exec(command)以及通过

ProcessBuilder pb = new ProcessBuilder("plink", "-pw", "***","username@hostname","tail","-1000","/temp/info.txt")

A user's environment is typically not in effect when a program is run via certain intermediary actors since a shell's PATH is set in .bashrc, to be executed anew with each new shell.当程序通过某些中间参与者运行时,用户的环境通常不起作用,因为 shell 的 PATH 设置在 .bashrc 中,每个新 shell 都会重新执行。

So, a Java process, for instance, doesn't even run a shell, hence a search in PATH's directories isn't made.因此,例如,Java 进程甚至不运行 shell,因此不会在 PATH 的目录中进行搜索。

Use full pathnames for programs run via Process on this and via remote execution services on another system.对通过此系统上的 Process 和另一个系统上的远程执行服务运行的程序使用完整路径名。

需要给出plink的完整路径,像这样C:\\Program Files\\PuTTY\\plink.exe -pw **** username@hostname tail -1000 /temp/info.txt

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 java.io.IOException:无法运行程序“mysql”:CreateProcess error=2,系统找不到指定的文件 - java.io.IOException:Cannot run program “mysql”:CreateProcess error=2, The system cannot find the file specified java.io.IOException:无法运行程序“”:CreateProcess error = 2,系统找不到指定的文件 - java.io.IOException: Cannot run program “”: CreateProcess error=2, The system cannot find the file specified java.io.IOException:无法运行程序“sqlldr”:CreateProcess error = 2,系统找不到指定的文件 - java.io.IOException: Cannot run program “sqlldr”: CreateProcess error=2, The system cannot find the file specified java.io.IOException:无法运行程序“ WMIC”:CreateProcess错误= 2,系统找不到指定的文件 - java.io.IOException: Cannot run program “WMIC”: CreateProcess error=2, The system cannot find the file specified java.io.IOException:无法运行程序“ tskill”:CreateProcess错误= 2,系统找不到指定的文件 - java.io.IOException: Cannot run program “tskill”: CreateProcess error=2, The system cannot find the file specified java.io.IOException:无法运行程序“。\\ bin \\ catalina.bat”-CreateProcess错误= 2,系统找不到指定的文件 - java.io.IOException: Cannot run program “.\bin\catalina.bat” - CreateProcess error=2, The system cannot find the file specified e:java.io.IOException:无法运行程序“ java -jar bg.jar”:CreateProcess错误= 2,系统找不到文件 - e: java.io.IOException: Cannot run program “java -jar bg.jar”: CreateProcess error=2, The system cannot find the file java.io.IOException:Cannot run program "sh" (in directory "c:\\cygwin\\bin\\test"):CreateProcess error=2.The system cannot find file specified - java.io.IOException:Cannot run program “sh” (in directory“c:\cygwin\bin\test”):CreateProcess error=2.The system cannot find file specified 引起:java.io.IOException:CreateProcess error = 2,系统找不到AWS指定的文件 - Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the file specified with AWS 由以下原因引起:java.io.IOException:CreateProcess错误= 2,系统找不到指定的文件 - Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the file specified
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM