1

I have tried this for my Script:

#!/bin/sh
gnome-terminal -- cd Server
gnome-terminal -- ./start.sh

However when I run it I get this error:

It also opens two terminals when I just want one with two commands.

There was an error creating the child process for this terminal

Failed to execute child process “cd” (No such file or directory)

How do I get the commands to run correctly?

I am on Ubuntu 19.04 and a complete newbie.

tdubz
  • 41
  • 3
  • 5
  • 2
    Does this answer your question? [script to open terminal, run command and keep terminal open](https://askubuntu.com/questions/928536/script-to-open-terminal-run-command-and-keep-terminal-open) Also, 19.04 went EoL in January, and is no longer supported. – mikewhatever Apr 18 '20 at 14:18

1 Answers1

5

cd is a shell builtin command - you can't execute it directly in a terminal, it needs a shell.

So for example

gnome-terminal -- sh -c 'cd Server && ./start.sh'

(you may need to give an absolute /path/to/Server depending on where you are running the command from).

steeldriver
  • 131,985
  • 21
  • 239
  • 326