[ILUG] Running command after login.

Niall O Broin niall at linux.ie
Thu Sep 27 12:55:24 IST 2001


On Thu, Sep 27, 2001 at 12:09:00PM +0100, Aherne Peter-pahern02 wrote:

> Actually what I need is
> 
> if (`userchoice` == "server1") 
> 
> rsh hostname	command1 #Then god damn stay in the host
> else 
> 
> rsh hostname	command2 #Then god damn stay in the host

OK - here's an answer which nearly works. Create a shell script called
command1 (or whatever) which simply has

#!/bin/sh
real_command1
exec bash -i


I say this nearly works for two reasons:

I tested it on Linux using bash, the default Linux shell. As you say ssh is
not an option, I've a sneaking suspicion you're perhaps using the group for
free help with some other *ix :-) in which case you may not have bash and
you may have to invoke the shell differently.

The remote environment is not set up correctly. The terminal type was not
picked up in my tests, and even when I set the terminal type manually the
arrow keys still did not work. Fixing these trivia is either a) unimportant
or b) left as an exercise for the reader. (BTW bash --login didn't work for
me in case that occured to anyone. bash --login -i did work but was just the
same)


That should put you on the path to righteousness. If you'd like a complete
solution with bells and whistles, please feel free to contact me privately
to arrange some consultancy :-)



Niall




More information about the ILUG mailing list