【问题标题】:execute a batch file (psexec.exe) from R console从 R 控制台执行批处理文件 (psexec.exe)
【发布时间】:2015-10-20 17:26:40
【问题描述】:

我正在运行一个 redis 服务器来扩展机器学习算法的核心数量。要在另一台计算机上创建工作人员,我需要执行一个批处理文件,在联网计算机上启动它们。我可以在本地机器上启动它们,并通过 .bat 文件中的 psexec.exe 命令让它们在远程机器上运行。但是,我还需要能够从我的 R 控制台调用这个 .bat 文件以使其成为一个一体化系统,这样我就不必每次运行新模型时都手动启动它们。

当我在 R 控制台中运行系统(命令)以启动 .bat 文件时,出现错误:

'PsExec.exe' is not recognized as an internal or external command,
operable program or batch file.
Warning message:
running command 'C:\remoterun.bat' had status 1 

我调用的系统命令是:

system("C:\\remoterun.bat")

是否可以在 R 中执行 .bat 文件以在 R 之外运行?是否有另一个我可以运行的 cmd 类型命令与我可以在 R 中运行的 psexec 执行相同的操作?

谢谢!

【问题讨论】:

  • 您的批处理文件中是否定义了 PSEXEC 的路径?
  • 不,它只是 PsExec.exe \\remoteIpAddress

标签: r batch-file cmd redis psexec


【解决方案1】:

看起来 PsExec.exe 路径未在 bat 文件中定义。您可以将 PsExec.exe 路径添加到 Windows 路径。在此处查看有关 Windows 路径的帮助:http://www.computerhope.com/pathhlp.htm 您还可以查看 shell() 命令,如下所示进行测试。

res <- shell("date /T", intern=TRUE)

希望对你有帮助。

【讨论】:

  • shell 是 Linux,而不是 Windows,但 cmdbatch-file 都是 Windows 特定的...
  • 做到了,谢谢!我在环境路径中缺少 psexec
  • @CooperBuckeye05,您可以将整个路径包含在批处理文件中。
猜你喜欢
  • 2012-05-08
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2010-11-02
  • 2016-09-09
  • 2012-12-26
相关资源
最近更新 更多