0

I'm kind of confused, I thought doing something like this would work :

#!/bin/bash

wget https://myscript.sh
chmod +x myscript.sh
exec gnome-terminal --tab --active --title="my title" -- myscript.sh

But running this returns :

error message in terminal

There was an error creating the child process for this terminal

Failed to execute child process "myscript.sh" (No such file or directory)

Removing exec doesn't work I also tried putting the file name in between $( ) and " ", I also tried putting the absolute path.

What am I doing wrong?

tatsu
  • 3,008
  • 3
  • 40
  • 71

1 Answers1

0

The correct syntax is :

gnome-terminal --tab --active --title="my title" -- "/tmp/myworkdir/myscript.sh"

having an absolute path will allow for the file to be run.

make sure to makes all your file operations happen in this same directory.

tatsu
  • 3,008
  • 3
  • 40
  • 71
  • That just means that `myscript.sh` either doesn't have a shebang line or isn't executable or both. – terdon Jul 19 '19 at 11:41
  • I just did, and a script with `#!/bin/bash` as the first line, and then `echo foo; sleep 100` will run fine with `gnome-terminal --tab --active --title="my title" -- foo.sh`. It actually fails with `bash foo.sh`! – terdon Jul 19 '19 at 12:40
  • Tried both, no difference. Are you _sure_ you have a correct shebang line? – terdon Jul 19 '19 at 13:08
  • Let us [continue this discussion in chat](https://chat.stackexchange.com/rooms/96387/discussion-between-terdon-and-tatsu). – terdon Jul 19 '19 at 13:58
  • IMO it should be `gnome-terminal --tab --active --title="my title" -- bash -c "/path/myscript.sh; exec bash"`, reference: https://askubuntu.com/a/974782/566421 – pa4080 Jul 19 '19 at 15:46