Find the answer to your Linux question:
Results 1 to 8 of 8
Hello, I want to write a bash script which can open a new gnome-terminal window. In that gnome-terminal window, it should goto a specific directory and edit a file using ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Apr 2010
    Posts
    5

    Smile Bash Script to start Gnome Terminal


    Hello,

    I want to write a bash script which can open a new gnome-terminal window.
    In that gnome-terminal window, it should goto a specific directory and edit a file using Vi Editor.

    How is it possible to do that?

    Thanks,
    Raj.

  2. #2
    Linux Engineer GNU-Fan's Avatar
    Join Date
    Mar 2008
    Posts
    935
    Type and read:
    Code:
    man gnome-terminal
    Debian GNU/Linux -- You know you want it.

  3. #3
    Just Joined!
    Join Date
    Apr 2010
    Posts
    5
    Dear GNU-Fan,

    I read the Man pages and tried to execute these 2 commands-
    Code:
    gnome-terminal --command="cd /usr/src"
    gnome-terminal --execute cd /usr/src
    the Gnome terminal opens, and it says there was error creating child process for this terminal.

    Thanks,
    Raj.

  4. $spacer_open
    $spacer_close
  5. #4
    Just Joined! sixdrift's Avatar
    Join Date
    Jan 2007
    Location
    In and around and about Cary, NC
    Posts
    44
    This worked on the command line.
    Code:
    gnome-terminal -e "vi $HOME/debug/junk/test.file"
    Substitute the path of your own choosing.

  6. #5
    Just Joined!
    Join Date
    Apr 2010
    Posts
    5
    Thanks sixdrift
    it has worked for me too...
    though i wanted to know if it was possible to change the directory.
    looks like it is not possible.

  7. #6
    Just Joined! sixdrift's Avatar
    Join Date
    Jan 2007
    Location
    In and around and about Cary, NC
    Posts
    44
    It is possible if you write a script that does all the sequences you want and then you launch the script using gnome-terminal -e "scriptname"

  8. #7
    Just Joined!
    Join Date
    Apr 2010
    Posts
    5
    alright !
    thanks a lot

  9. #8
    Linux Engineer GNU-Fan's Avatar
    Join Date
    Mar 2008
    Posts
    935
    There is also an option "working-directory".
    Debian GNU/Linux -- You know you want it.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •