3

So I have a sh script which is located in my Downloads folder. Using this script I managed to open the terminal at the specific folder:

String command = "/usr/bin/nome-terminal.wrapper"; 
File workDir = new File("/home/user/Downloads");
Runtime rt = Runtime.getRuntime();
Process pr = rt.exec(command, null, workDir)

And than I wanted to run the script after the terminal was loaded so I replaced the script above with this:

String command= "/usr/bin/nome-terminal.wrapper -e 'myScript.sh; bash'";
File workDir = new File("/home/user/Downloads");
Runtime rt = Runtime.getRuntime();
Process pr = rt.exec(command, null, workDir)

But the error I get is: here was an error creating the child process for this terminal. Failed to execute child process “'myScript” (No such file or directory)

Note: I don't want to run the script directly. I want the terminal to run it

UPDATE

I tried using this :

String[] cmdArray = new String[2];
cmdArray[0] = "usr/bin/gnome-terminal.wrapper";
cmdArray[1] = "myScript.sh";

Process process = Runtime.getRuntime().exec(cmdArray, null,new File("/home/user/Downloads"));

but I get the error: java.io.IOException: Cannot run program "usr/bin/gnome-terminal.wrapper" (in directory "/home/user/Downloads"): error=2, No such file or directory as he tries to find the terminal exe inside my Downloads folder.

tripleee
  • 175,061
  • 34
  • 275
  • 318
plshm
  • 288
  • 3
  • 20
  • did u check this https://stackoverflow.com/questions/15356405/how-to-run-a-command-at-terminal-from-java-program – pvpkiran Aug 10 '18 at 07:47
  • @pvpkiran I tried it still didn't work. See edit – plshm Aug 10 '18 at 08:10
  • @pvpkiran any ideas what the problem might be – plshm Aug 10 '18 at 10:07
  • You mistyped the name of `/usr/bin/gnome-terminal.wrapper` in every instance. That's probably not the whole problem but try fixing the obvious typos. There's a slash as the first character and a `g` after the last slash. (There should be no need to type out the full path if it's in your `PATH`, per se.) – tripleee Sep 25 '18 at 04:27

0 Answers0