As for the cd
command: Do not surround the command in quotes.
The reason: The actual command is called cd
; the parameter to that command is /home/tester/python/
. By putting the whole command line in quotes, you're basically telling the shell to run a program named cd /home/tester/python/
, which obviously doesn't exist; only a program called cd
exists, and that program can accept /home/tester/python/
as a parameter. (I hope I made that clear enough.) So to summarize: Delete the quotes.
As for the unexpected popup: When you go to close a terminal window or tab, the MATE Terminal is smart enough to check if the program you're running in the terminal (usually a shell, though in this case a shell interpreting your script) has executed any currently-running processes. That means that if you close a terminal window with just bash
siting there doing nothing, waiting for your input, the terminal program will not prompt you before closing the window; on the other hand, if you're running another program in the shell; the terminal will prompt you before closing the terminal window. (This test is done since there's always the possibility of messing something up if you abruptly close the terminal and kill running commands; if you were running apt dist-upgrade
to upgrade your Ubuntu MATE system, would you be a happy camper if you interrupted the upgrade by accidentally clicking on the little 'X' button on the terminal window? Chances are, no.) So what second program are you running in the terminal? Answer: A second copy of bash
, like line 3 of your script says.
Short answer: If you want to avoid the unexpected behavior of the terminal prompting you before closing the window, prepend an exec
command to the last command in the script, in this case bash
. (Presumably, you'll eventually change the bash
at the end to something like python script1.py
, but prepending an exec
to that will work too.) The exec
replaces the shell that is running the active shell script with a program of your choosing. Because the shell running the active shell script gets replaced, the terminal doesn't notice any "child" processes and assumes it's OK to close the window without prompting.
To summarize, your script should look like this after following all of my directions:
#! /bin/bash
cd /home/tester/python/
exec bash
Side note: If this is supposed to be a "wrapper script" and you want to pass all parameters to the wrapper script on to the last command in the script (the "wrapped" command), you can change the last line to read:
exec bash $@
I wish you luck on this script.