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.

4
  • did u check this stackoverflow.com/questions/15356405/… Commented Aug 10, 2018 at 7:47
  • @pvpkiran I tried it still didn't work. See edit Commented Aug 10, 2018 at 8:10
  • @pvpkiran any ideas what the problem might be Commented Aug 10, 2018 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.) Commented Sep 25, 2018 at 4:27

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.