0

I am trying to run a bash script which contains few commands to execute. I want to open a terminal and execute multiple commands into it. I have written commands to set the directory path and want to make a folder there.

Code :

gnome-terminal --working-directory=/var/run/ 
gnome-terminal -e "bash -c \"sudo mkdir sphinxsearch; exec bash\""

Here, There are 2 problems :

1) Two separate terminal are opened that I don't want. I need only a single terimal where I will execute my commands.

2) sudo mkdir sphinxsearch folder is created at the default path from where I am executing my bash script. I need to create a folder inside /var/run/

iNikkz
  • 3,729
  • 5
  • 29
  • 59

2 Answers2

1

Each invocation of gnome-terminal will open a separate terminals.

Try this:

gnome-terminal --working-directory=/var/run/ -e "bash -c \"sudo mkdir sphinxsearch; exec bash\""

Here i am combining both options in a single invocation of gnome-terminal

Fazlin
  • 2,285
  • 17
  • 29
1
sudo mkdir /var/run/sphinxsearch;

will create the folder in /var/run/

nu11p01n73R
  • 26,397
  • 3
  • 39
  • 52