[英]Run the date command in Spring Shell (“Cannot run program … the system cannot find the file specified”)
As per the documentation which says 根据说明的文件
OsCommands - the keyword for this command is the exclamation point, after the exclamation point you can pass in a Unix/windows command string to be executed
OsCommands-此命令的关键字是感叹号,在感叹号之后,您可以传入要执行的Unix / windows命令字符串
This means, we can execute OS commands in Spring Shell by prefixing the OS command with !
这意味着,我们可以通过在OS Shell中添加
!
前缀来执行OS Shell中的OS命令!
(exclamation). (感叹)。
But I believe there is some issue or I am missing something. 但是我相信这里有些问题,或者我缺少一些东西。 When I tried, I got the below error.
当我尝试时,出现以下错误。
hw-shell>! date
command is: date
Unable to execute command date [Cannot run program "date" (in directory "."): CreateProcess error=2, The system cannot find the file specified]
I thinks you may be forgot to set class path in your spring shell class,Set the class path using below line then try... 我认为您可能忘记了在Spring Shell类中设置类路径,使用下面的行设置类路径,然后尝试...
new ClassPathXmlApplicationContext("classpath*:/META-INF/spring/spring-shell-plugin.xml");
For More Reference: http://docs.spring.io/spring-shell/docs/current/reference/html/shell.html 有关更多参考: http : //docs.spring.io/spring-shell/docs/current/reference/html/shell.html
根据异常消息的缺失,您是否在Windows的%PATH%环境中真正拥有了“日期”命令。
"date" is a built-in command of the windows command shell. “日期”是Windows命令外壳程序的内置命令。 It seems that these built-in commands are not available within spring-shell and spring-shell looks after commands which exist real as file in the windows path.
似乎这些内置命令在spring-shell中不可用,并且spring-shell会照看在Windows路径中以文件形式实际存在的命令。
Windows-Commands like calc ( ! calc
) which are not built-in are available. 可以使用非内置的Windows命令,例如calc(
! calc
)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.