简体   繁体   English

通过以JAVA开头的C ++应用程序运行Shell脚本

[英]Running A Shell Script Through A C++ app Started With JAVA

My requirement is to start a c++ application which runs some shell scripts in a certain folder. 我的要求是启动一个C ++应用程序,该应用程序在某个文件夹中运行一些Shell脚本。 the c++ app is started with java. C ++应用程序是用Java启动的。 The scripts its trying to run have being given chmod 777 access as well as the jar is started with sudo and the util is started with sudo from within the jar. 尝试运行的脚本已被授予chmod 777访问权限,并且jar是从sudo启动的,util是从jar中的sudo启动的。

My problem is the scripts fail to run soemtimes saying script failed to run returned: 512 (the script is just an echo) I am running all command line function in java using getRuntime.exec (I tried process builder too) TLDR: jar starts c++ app c++ app tries to run shell script script fails sometimes Anyone got any suggestions or faces similar situation ? 我的问题是脚本无法运行soemtimes表示脚本无法运行返回:512(脚本只是回显)我正在使用getRuntime.exec在Java中运行所有命令行功能(我也尝试过使用流程生成器)TLDR:jar启动c ++ app c ++ app尝试运行shell脚本脚本有时会失败有人收到任何建议或面临类似情况吗?

EDIT 1 I should also mention that the scripts are being downloaded first via java. 编辑1我还要提到的是,这些脚本首先是通过Java下载的。 and then only passed on to the c++ app. 然后仅传递给c ++应用。 The c++ utility works fine with scripts which are already there.I am using apache http client C ++实用程序可以与已经存在的脚本一起正常工作。我正在使用apache http client

我设法解决了这个问题,当c ++应用程序试图访问脚本时,仍然有一个输出流。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM