I would like to do the following:
- Open a terminal.
- Change to the directory where target script resides.
- Open the text file which provides the input to the target script. Hold/wait until the user has saved and closed the text file.
- Execute the target script.
I wrote the following script to do the above:
#!/bin/bash echo "hello" gnome-terminal -x bash -c "cd ~/Scripts;pwd;gedit input.txt;python test.py;exec $SHELL" echo "good bye"
The above gives me the following output:
user4@user-pc-4:~/Desktop$ ./DAT_run.sh hello good bye
And on the new gnome-terminal opened, I see the following message:
/home/user4/Scripts From python script From python script From python script From python script From python script
The above means it has executed the python code and my requirements 1,2 and 4 have been met (not the 3rd). I'm unable to hold the
gedit window until it has been saved and closed.
What I'm wondering is - why is the
gedit command being treated as a background process when I have not indicated any such thing by writing
& at the end of the statement? How can I make sure that my
gedit is running as a foreground process and requires the user to take control?
What could be going wrong here? I am new to shell scripting and feel like I could very well be missing something here. How can I achieve all my above requirements?
nanoinstead. It should run in the opened terminal.