Cd to a Directory and Issue a Shell Command Using Gnome Terminal Command

Cd to a Directory and Issue a Shell Command Using Gnome Terminal Command

I have a folder Parent folder which contains a script mytestcase.sh

parent_folder/mytestcase.sh

I am in Home directory .How can I start a new terminal using GNOME TERMINAL command, CD to parent_folder and issue the above script. The output of a new terminal should CD to Parent_folder and later issue the mytestcase.sh.

0

1 Answer

You can run the following:

gnome-terminal --window --working-directory /full/path/to/parent_folder -- ./mytestcase.sh

If you want to keep the terminal open after execution of mytestcase.sh ends:

Method 1. Modify your mytestcase.sh script to add at the end a command like:

read DUMMY

This will wait until you press ENTER and then the terminal window will close.

Method 2. Use a custom profile in GNOME Terminal. In Preferences, define a new profile (let's call it noclose) and in the "Command" tab, choose the option to keep the window open after the command finishes. Then call gnome-terminal with the following command:

gnome-terminal --window-with-profile=noclose --working-directory /full/path/to/parent_folder -- ./mytestcase.sh
2

Your Answer

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

Alexander Ross
Author

Alexander Ross

Alexander Ross has covered the video game industry for a decade, writing deep dives on game design, esports tournaments, VR developments, and gaming culture.