Remote command execution via SSH and newgrp command
Hi,
Up until now I've been using plink to remotely compile a project I'm working on. But recently the administrator from the remote server updated the distribution and messed up some configurations. My project has a lot of scripts written for tc shell (tcsh), and now the default shell is bash. There is no way to change this. Another problem is that now I need to run newgrp to change my default user group. So... to work around this problem I've changed my .bashrc to run newgrp and then tcsh. If I do a normal connection using SSH, everything works as expected, but when using plink, or SSH to remotely execute commands, the shell gets stuck on the newgrp command. I think it's because both applications need a return value from newgrp to send the command I need to execute. Remotely running scripts that call a shell also get stuck like newgrp (newgrp also opens a new shell and that's why it gets stuck) my .bashrc is as follows: Code:
user_grp=`id -g` Thanks |
Quote:
Quote:
Code:
if [ $user_grp != 4919 ]; then |
Actually the infinite loop is not the problem, I took care of that with my "if" statement, the second time the script is executed, my group is the right one, so it calls the tcsh instead.
This is working when I connect to the server by SSH, like: Code:
ssh server.com -lusername Code:
ssh server.com -lusername ls -s |
Yes, sorry. I can see it now: the problem is that the command is passed to the login shell /bin/bash but a new shell /bin/tcsh is spawned and it is not aware of the command to execute. Unless you pass it to the spawn explicitly!
Now the problem can be reduced to: if the shell is interactive then open a tcsh session, otherwise if the shell is non-interactive execute the command using tcsh then exit. Translated in bash: Code:
if [[ $- =~ i ]] |
Excelent!! That's it!
Thank you very much... |
All times are GMT -5. The time now is 06:22 AM. |