LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   ?> best way to call another shell from login configuration (https://www.linuxquestions.org/questions/linux-newbie-8/best-way-to-call-another-shell-from-login-configuration-4175561803/)

tsester 12-18-2015 04:33 PM

?> best way to call another shell from login configuration
 
what is the proper way to call another shell from the current one using shell configuration files

hello, i login to a remote terminal which uses tcsh. If i run /bin/bash by entering the command in the prompt, everything seems ok. if i call it in .cshrc there are problems, though.
I cannot "chsh -s /bin/bash" because "users '...' does not exist in /etc/passwd" . ~/.cshrc is run everytime i login. here's what i tried:
.cshrc :
Code:

cat .cshrc
# @(#)cshrc 1.11 89/11/29 SMI
umask 022
set path=(/home/newapps/SUNWspro/bin /home/appl/gcc/bin /home/appl/gdb/bin /usr/ccs/bin /usr/bin/X11 /bin /usr/bin /home/appl/mosaic /usr/ucb /etc /usr/etc /usr/local/bin /home/appl/emacs/bin /home/appl/ghostscript/bin /home/appl/gzip/bin .)
if ( $?prompt ) then
    setenv LC_CTYPE el_GR.utf8
    stty cs8 -istrip -parenb
    set history=32
endif
alias cd 'cd \!*; set prompt = `hostname`\:$cwd\>'
alias ls 'ls -lF'
#alias rm 'rm -i'
alias lo 'logout'
alias mail '/usr/ucb/mail'
set prompt = `hostname`\:$cwd\>
set filec
limit coredumpsize 0
# editted after this line:
# 1st try
tty --quiet && exec /bin/bash #also with --login
# also tried (2nd try)
#tty --quiet && /bin/bash #also with --login

the problem is found in cgdb with a sample small program called main.c .
cgdb ./main (1st try):
Code:

(gdb) run
Starting program: /home/users1/sdi1500122/ip/lab-2015.12.18/main
Cannot access memory at address 0xea6bd464
Cannot access memory at address 0xea6bd460
(gdb)

(2nd try) when i hit "run" i get
Code:

(gdb) run
Starting program: /home/users1/sdi1500122/ip/lab-2015.12.18/main sdi1500122@linux27:~/ip/lab-2015.12.18$

in the 2nd try, i cannot <Ctrl>+C or "quit". I can however <Ctrl>+Z and kill it with pkill -KILL cgdb.

Here's the program used (for reference):
Code:

cat main.c
#include <stdio.h>

#define N 5

int main(void){
    int i,j,arr[N][N];
    for (i=0; i < N; i++){
        for (j=0; j < N; j++){
            if ( i == j )
                arr[i][j] = 1;
            else
                arr[i][j] = 0;
        }
    }
    for (i=0; i < N; i++){
        for (j=0; j < N; j++){
            printf("%i ",arr[i][j]);
        }
        printf("\n");
    }
/*    int (*i)[10];
    printf("%x\n",i);
    int *j[10];
    printf("%x\n",j);
*/    return 0;
}

If you suspect it is related to gdb /cgdb only, please let me search for it:
Code:

cgdb:
CGDB 0.6.5

gdb:
GNU gdb (Ubuntu/Linaro 7.4-2012.04-0ubuntu2.1) 7.4-2012.04

ubuntu:
cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=12.04
DISTRIB_CODENAME=precise
DISTRIB_DESCRIPTION="Ubuntu 12.04.5 LTS"

tcsh:
tcsh 6.17.06 (Astron) 2011-04-15 (i686-intel-linux) options wide,nls,dl,al,kan,rh,nd,color,filec

bash:
GNU bash, version 4.2.25(1)-release (i686-pc-linux-gnu)

#
ulimit -a # in bash
core file size          (blocks, -c) 0
data seg size          (kbytes, -d) unlimited
scheduling priority            (-e) 0
file size              (blocks, -f) unlimited
pending signals                (-i) 15990
max locked memory      (kbytes, -l) 64
max memory size        (kbytes, -m) unlimited
open files                      (-n) 1024
pipe size            (512 bytes, -p) 8
POSIX message queues    (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) 8192
cpu time              (seconds, -t) unlimited
max user processes              (-u) 15990
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited


berndbausch 12-18-2015 05:40 PM

Quote:

Originally Posted by tsester (Post 5466086)
what is the proper way to call another shell from the current one using shell configuration files

hello, i login to a remote terminal which uses tcsh. If i run /bin/bash by entering the command in the prompt, everything seems ok. if i call it in .cshrc there are problems, though.
I cannot "chsh -s /bin/bash" because "users '...' does not exist in /etc/passwd" .

Is '...' the account under which you log in?
Can you read /etc/passwd?
Can you run chsh -s /bin/bash whateveruseryouareloggedinas?

And perhaps post the result of the id command and the exact error message of chsh.

Quote:

Originally Posted by tsester (Post 5466086)
~/.cshrc is run everytime i login. here's what i tried:
.cshrc :
Code:

cat .cshrc
# @(#)cshrc 1.11 89/11/29 SMI
umask 022
set path=(/home/newapps/SUNWspro/bin /home/appl/gcc/bin /home/appl/gdb/bin /usr/ccs/bin /usr/bin/X11 /bin /usr/bin /home/appl/mosaic /usr/ucb /etc /usr/etc /usr/local/bin /home/appl/emacs/bin /home/appl/ghostscript/bin /home/appl/gzip/bin .)
if ( $?prompt ) then
    setenv LC_CTYPE el_GR.utf8
    stty cs8 -istrip -parenb
    set history=32
endif
alias cd 'cd \!*; set prompt = `hostname`\:$cwd\>'
alias ls 'ls -lF'
#alias rm 'rm -i'
alias lo 'logout'
alias mail '/usr/ucb/mail'
set prompt = `hostname`\:$cwd\>
set filec
limit coredumpsize 0
# editted after this line:
# 1st try
tty --quiet && exec /bin/bash #also with --login
# also tried (2nd try)
#tty --quiet && /bin/bash #also with --login


I don't see bash called.

The rest of your post seems to have nothing to do with your problem.

Quote:

Originally Posted by tsester (Post 5466086)
the problem is found in cgdb with a sample small program called main.c .
cgdb ./main (1st try):
Code:

(gdb) run
Starting program: /home/users1/sdi1500122/ip/lab-2015.12.18/main
Cannot access memory at address 0xea6bd464
Cannot access memory at address 0xea6bd460
(gdb)

(2nd try) when i hit "run" i get
Code:

(gdb) run
Starting program: /home/users1/sdi1500122/ip/lab-2015.12.18/main sdi1500122@linux27:~/ip/lab-2015.12.18$

in the 2nd try, i cannot <Ctrl>+C or "quit". I can however <Ctrl>+Z and kill it with pkill -KILL cgdb.

Here's the program used (for reference):
Code:

cat main.c
#include <stdio.h>

#define N 5

int main(void){
    int i,j,arr[N][N];
    for (i=0; i < N; i++){
        for (j=0; j < N; j++){
            if ( i == j )
                arr[i][j] = 1;
            else
                arr[i][j] = 0;
        }
    }
    for (i=0; i < N; i++){
        for (j=0; j < N; j++){
            printf("%i ",arr[i][j]);
        }
        printf("\n");
    }
/*    int (*i)[10];
    printf("%x\n",i);
    int *j[10];
    printf("%x\n",j);
*/    return 0;
}

If you suspect it is related to gdb /cgdb only, please let me search for it:
Code:

cgdb:
CGDB 0.6.5

gdb:
GNU gdb (Ubuntu/Linaro 7.4-2012.04-0ubuntu2.1) 7.4-2012.04

ubuntu:
cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=12.04
DISTRIB_CODENAME=precise
DISTRIB_DESCRIPTION="Ubuntu 12.04.5 LTS"

tcsh:
tcsh 6.17.06 (Astron) 2011-04-15 (i686-intel-linux) options wide,nls,dl,al,kan,rh,nd,color,filec

bash:
GNU bash, version 4.2.25(1)-release (i686-pc-linux-gnu)

#
ulimit -a # in bash
core file size          (blocks, -c) 0
data seg size          (kbytes, -d) unlimited
scheduling priority            (-e) 0
file size              (blocks, -f) unlimited
pending signals                (-i) 15990
max locked memory      (kbytes, -l) 64
max memory size        (kbytes, -m) unlimited
open files                      (-n) 1024
pipe size            (512 bytes, -p) 8
POSIX message queues    (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) 8192
cpu time              (seconds, -t) unlimited
max user processes              (-u) 15990
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited



tsester 12-18-2015 05:45 PM

Code:

id:
uid=15049(sdi1500122) gid=170(undergr) groups=170(undergr)

Quote:

Can you read /etc/passwd?
yes
Code:

chsh -s /bin/bash
Password:
chsh: user 'sdi1500122' does not exist in /etc/passwd

"I don't see bash called."
Quote:

tty --quiet && exec /bin/bash

like100ninjas 12-18-2015 09:30 PM

tried changing shell variable beforehand like this?

Code:

SHELL=/usr/bin/bash && exec /usr/bin/bash
if you can't rig a way around it you'd need to contact an admin and have them change your default shell.

tsester 12-18-2015 09:36 PM

Quote:

Originally Posted by like100ninjas (Post 5466184)
tried changing shell variable beforehand like this?

Code:

SHELL=/usr/bin/bash && exec /usr/bin/bash
if you can't rig a way around it you'd need to contact an admin and have them change your default shell.

thnx a lot. it worked! the actual command for csh-like is :
Code:

setenv SHELL /bin/bash && exec /bin/bash
:)

jpollard 12-18-2015 09:52 PM

Or use "exec /bin/bash -l" which directs bash to be a login shell.

BTW, the reason chsh may not work is if the login is coming from LDAP and is not a local login.

like100ninjas 12-18-2015 09:58 PM

o sry. never tried using csh before. yeah, probably wouldn't be a login shell without the -l if you called it from your .cshrc, huh?

tsester 12-18-2015 10:06 PM

Quote:

Originally Posted by jpollard (Post 5466196)
Or use "exec /bin/bash -l" which directs bash to be a login shell.

BTW, the reason chsh may not work is if the login is coming from LDAP and is not a local login.

No, it didn't work.. (How can i check if it is ldap?)

like100ninjas 12-18-2015 10:17 PM

it probably is. that's why your username isn't in /etc/passwd and chsh doesn't work. the -l flag doesn't work tacked onto the line you said worked earlier?

jpollard 12-19-2015 03:30 AM

Quote:

Originally Posted by like100ninjas (Post 5466198)
o sry. never tried using csh before. yeah, probably wouldn't be a login shell without the -l if you called it from your .cshrc, huh?

Not after the exec.


All times are GMT -5. The time now is 03:02 PM.