Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do take user to remote box and change directory and stay there

Status
Not open for further replies.

fixengineer

Technical User
Apr 5, 2007
19
US
Here is the code:

ssh -l login $userserver "cd $userpath; $mycommands"

At my company we have many Linux/UNIX servers and my script is supposed to automate navigation between the boxes. My script will reside on a single server and should be capable of taking user to another box, changes the directory, then passing control back to user. Problem is the above command runs and then returns you to the original box.

I ended up echoing the commands to the user, so they can copy and paste the commands. I want to eliminate that. The box should take you to the box and directory you need and then pass control to you. You should never have to do anything outside of the script to navigate.

Any ideas? This is a fundamental flaw in my script. Thanks!
 
What about this ?
ssh -l login $userserver "cd $userpath; $mycommands; echo 'Type exit when done'; exec $SHELL"


Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Do you use Exceed or some other X windows server on the PC side (assuming users are at a pc)?

If so, you could do something like this:

ssh -l <username> <remote system> xterm -display <pc ip address> &

You would need to figure out the PCs IP address - but that should be simple to grab from the "who" info on the original system. The actual command might look like this:

ssh -l joe systemx xterm -display 172.16.34.23:0.0 &

The end result is that the remote system starts an xterm and displays it on the local pc. The original window can be logged out (or do other things) without affecting the xterm that was started.
 
No X-Windows unfortunately.

ssh -l login $userserver "cd $userpath; $mycommands; echo 'Type exit when done'; exec $SHELL"

The above works great, except for the fact that if the user tries to use something like vi, the display gets messed up. I'll see if I can figure out a work around.
 
And this ?
ssh [!]-t [/!]-l login $userserver "cd $userpath; $mycommands; echo 'Type exit when done'; exec $SHELL"

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
WOW!! Thats great! That works perfectly! That will take my script to a whole new level of functionality. Thank you very much! That was the missing piece I needed. Now to work on incorporating basic AI.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top