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

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

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

You Might Also Like