简体   繁体   English

在Spring Shell中运行date命令(“无法运行程序……系统找不到指定的文件”)

[英]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.

相关问题 Java执行shell命令-错误[无法运行程序“sh”:CreateProcess错误=2,系统找不到指定的文件] - Java execute shell command - error [Cannot run program "sh": CreateProcess error=2, The system cannot find the file specified] 没有生根的android无法运行shell命令 - Cannot run the shell command without rooting android crontab 无法使用 docker 命令运行 shell 脚本? - crontab cannot run shell script with docker command? TeamCity系统找不到指定的文件 - TeamCity The system cannot find the file specified 无法在 shell 中运行 jflex - Cannot run jflex in shell 无法通过 php exec 运行 shell 命令,但可以作为 shell 上的用户? - Cannot run shell command through php exec, but can as user on shell? 无法运行程序“ Rscript” - cannot run program “Rscript” MonkeyRunner无法在Git Shell上运行。 接收@echo:找不到命令 - MonkeyRunner cannot run on Git Shell. Receiving @echo: command not found 无法从Java命令行运行Shell脚本 - Cannot run shell script from java Command Line 通过java程序在IBM云中运行shell命令,将抛出java.io.IOException错误:无法运行program = 13,权限被拒绝 - Running a shell command in IBM cloud through java programme throwing error as java.io.IOException: Cannot run program =13, Permission denied
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM