bash - Executing shell-script with parameters from java -


I've been googling for a while, and everyone seems to have a different solution, none of which works for me is .

I have tried both process builder and runtime . Call both the .sh file directly and feed it to / bin / bash .

  string cmd [] = {"~ / path / to / shellscript.sh",    "foo", "bar"}; Process P = RuntimeGreat Time (). Exec (CMD);   

Despite the manual running is not giving any such file or directory

  ~ / path / to / Shellscript.sh foo Bar   

works perfectly with Bash.

I need to keep ~ because this shell script exists in slightly different forms, three different users.

One option is to handle ~ : < Pre> string homdir = System.getenv ("HOME"); String [] cmd = {homeDir + "/path/to/shellscript.sh", "foo", "bar"}; Process P = RuntimeGreat Time (). Exec (CMD);

Each other has to allow Bash to handle it for you:

  string [] cmd = {"bash", "-c", "~ / Path /to/shellscript.sh foo bar "}; Process P = RuntimeGreat Time (). Exec (CMD);    

Comments

Popular posts from this blog

Python SQLAlchemy:AttributeError: Neither 'Column' object nor 'Comparator' object has an attribute 'schema' -

java - How not to audit a join table and related entities using Hibernate Envers? -

mongodb - CakePHP paginator ignoring order, but only for certain values -