Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I run a script when I log in that basically looks like this:

chromium-browser &
xchat &
cd ~/randomdir && gnome-terminal &
qbittorrent &

On the third line (cd ~/randomdir && gnome-terminal &), I would like to run another script in the terminal that I'm opening up. How can I do that in this script?

share|improve this question
    
The below user has already posted an answer for you before your edit and you have edited your post and with another question. AU rules one Q per one post. –  AgentCool Oct 10 '13 at 16:09
    
Fine I did it for you. –  AgentCool Oct 10 '13 at 16:11
    
you might looking for askubuntu.com/questions/3359/… –  AgentCool Oct 10 '13 at 16:12

2 Answers 2

up vote 4 down vote accepted

Run a non-interactive shell that runs your script and then replaces itself with an interactive bash shell.

gnome-terminal --working-directory="$HOME/randomdir" -x bash -c './randomscript; exec bash' &
share|improve this answer

gnome-terminal --working-directory=randomdir

Is this what you are looking for?

By the way, man gnome-terminal should help :)

EDIT:

However, if you want to keep the terminal open you can do this:

gnome-terminal --working-directory=randomdir -e COMMAND #launch the command - terminal will close
gnome-terminal --working-directory=randomdir #open a new terminal with the same default path

These 2 commands added in your script.

share|improve this answer
    
This is not what I'm looking for, I want to launch another script in the newly opened terminal, and keep the terminal open after that script exits. –  ike Oct 10 '13 at 16:02
    
from the OP "By the way I tried cd ~/rockbox && gnome-terminal -e "./randomscript.sh"& and that opened the script, but closed the terminal after the script exited." –  AgentCool Oct 10 '13 at 16:10
    
This works, but I like the other answer better because it keeps the same window, and the other commands in the file still run with their solution.(I couldn't get your's to do that, even with adding the &'s at the end of lines.) –  ike Oct 10 '13 at 16:43
    
I got it to run like I wanted it to by gnome-terminal --working-directory=randomdir -e ./randomscript.sh && gnome-terminal --working-directory=randomscript& –  ike Oct 10 '13 at 16:45

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.