I have a text-based game, Colossal Cave Adventure, that I would like to launch with a shell script instead of opening the terminal and typing cd ~/Desktop/CCA and ./Adventure. The code I am trying to use is this:

#! /bin/bash
gnome-terminal -e 'cd ~/Desktop/CCA/; ./Adventure'

and the message i receive is this:

There was an error creating the child process for this terminal
Failed to execute child process `cd` (No such file or directory)

with options to change profile preferences or relaunch the process. I have also tried using the absolute path instead of ~/, and all of my file names are correctly spelled and point to the right place. What is wrong?


cd is a shell builtin. you should use this:

#! /bin/bash
gnome-terminal --working-directory=/home/username/Desktop/CCA/ -e './Adventure'

The error

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

arises because cd is one of the SHELL BUILTIN COMMANDS and not an executable that you physically find on your Hard Disk.

To run it or the others built-in commands in you script you need to pass all the line to a bash invocation

 gnome-terminal -e '/bin/bash -c "cd ~/Desktop/CCA/; ./Adventure" '   

If there are no other internal command that you have to execute you can set the working directory for the gnome terminal, as just answered here:

gnome-terminal --working-directory=/home/username/Desktop/CCA/ -e './Adventure'

Ad nauseam: there are some alternatives:

If you are just in a terminal you can either do

  • an alias like
    alias Star_My_Game="cd ~/Desktop/CCA; ./Adventure "
    and put it in your .bashrc or in ~/.bash_aliases so that you will be able to run with the single command Start_My_Game in each shell you will be (It's more cosy to choose a simpler/short name than Start_My_Game...)

  • or a script that you can make executable (chmod u+x MYscript) and put in your path (tipically ~/bin is a good candidate).

I suppose you can put a link on your desktop that execute the terminal and modify the starting behaviour. From gnome help

  1. Select Edit ▸ Profile Preferences ▸ Title and Command.

  2. Check Run a custom command instead of my shell.

  3. In the text box, type the command or the desired shell.

  4. The command will be passed to the terminal exactly as you write it, including any arguments that you specify. Environment variables will be inherited from the terminal as it is a child process of the terminal.

    Open a new Terminal tab or window to see how the custom shell or command executes

  • But the point was to launch from a shell script, and not have to open a terminal window. – Giaphage47 May 28 '14 at 6:16
  • If you want to launch from a script is enough an alias (more cosy) or a script in your ~/bin directory, without to launch a new terminal – Hastur May 28 '14 at 6:19
  • Answer updated just in case you need again: it's possible to pass cd but you need to pass it to bash. Give it a check :) – – Hastur May 28 '14 at 7:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.