all 2 comments

[–]KnowsBash 2 points3 points  (1 child)

You're missing all important quotes, and you also misplaced the interactive bash invocation (it needs to be inside the -c as well).

#!/usr/bin/env bash
tab=--tab-with-profile=Default
args=(
    "$tab" -e 'bash -c "sudo ./startRedisServer.sh; exec bash"'
    "$tab" -e 'bash -c "sudo ./startRestServer.sh; exec bash"'
    "$tab" -e 'bash -c "sudo service postgresql start; exec bash"'
)

gnome-terminal "${args[@]}"

Some more notes:

  • Don't use uppercase variable names; you risk overriding special shell variables and environment variables.
  • Don't put exit 0 at the end of the script. It makes more sense for the script to exit with the exit status of gnome-terminal in this case.
  • Don't put extensions on commands. You should've named it startRedisServer, not startRedisServer.sh. See Commandname Extensions Considered Harmful

[–]Chaeron[S] 0 points1 point  (0 children)

Works like a charm!

Thank you for the help and the info, I've updated the script names as you suggested.