Tekforums

Chat => Entertainment & Technology => Topic started by: M3ta7h3ad on February 26, 2008, 11:59:07 AM

Title: Run script on opening a terminal window...
Post by: M3ta7h3ad on February 26, 2008, 11:59:07 AM
In work I work on various servers using ssh from one server to other servers in the work environment. (almost like an ssh proxy)

Ive written a little script to prompt for input for a server hostname and it makes the connection with the necessary settings.

Just wondering how I get this to run every time I open a terminal window? Tried .bash_profile but think that only comes into play when I first log into the server. Any ideas?
Title: Run script on opening a terminal window...
Post by: Mardoni on February 26, 2008, 15:44:05 PM
Not sure how to do what youre doing but a suggestion:

Add the script to the path and then you can just use it like an alias. i.e. I have a similar thing setup that appends the domain suffix to hostnames for me when I telnet. To telnet to one of these machines I do:

tel abc123

which runs my script; telnet abc123.xyz.com

hope that at least gives you a possible solution ?!?
Title: Re:Run script on opening a terminal window...
Post by: cornet on February 26, 2008, 20:58:58 PM
M3ta7h3ad...  You using Linux ?!

If using gnome-terminal then just right click in term, select "Edit this profile"
Under the "Title and Command" tab then set the Custom Command to the name of your script.

If plain old xterm then call

xterm -e



Actually I think that sticking the command in .bashrc rather than .bash_profile might do the trick as well since .bashrc is executed for every interactive shell where as .bash_profile is only executed per login shell.


Oh and also "necessary settings" ?! - If they are ssh settings then stick them in ~/.ssh/config