LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-18-2015, 05:33 PM   #1
tsester
Member
 
Registered: Dec 2011
Distribution: Gentoo
Posts: 46

Rep: Reputation: 2
Smile ?> 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
 
Old 12-18-2015, 06:40 PM   #2
berndbausch
Senior Member
 
Registered: Nov 2013
Location: Tokyo
Distribution: Redhat/Centos, Ubuntu, Raspbian, Fedora
Posts: 1,688

Rep: Reputation: 353Reputation: 353Reputation: 353Reputation: 353
Quote:
Originally Posted by tsester View Post
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 View Post
~/.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 View Post
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
 
Old 12-18-2015, 06:45 PM   #3
tsester
Member
 
Registered: Dec 2011
Distribution: Gentoo
Posts: 46

Original Poster
Rep: Reputation: 2
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
 
Old 12-18-2015, 10:30 PM   #4
like100ninjas
LQ Newbie
 
Registered: Apr 2015
Posts: 24

Rep: Reputation: Disabled
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.

Last edited by like100ninjas; 12-18-2015 at 10:33 PM.
 
1 members found this post helpful.
Old 12-18-2015, 10:36 PM   #5
tsester
Member
 
Registered: Dec 2011
Distribution: Gentoo
Posts: 46

Original Poster
Rep: Reputation: 2
Quote:
Originally Posted by like100ninjas View Post
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
 
Old 12-18-2015, 10:52 PM   #6
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,654

Rep: Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255
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.

Last edited by jpollard; 12-18-2015 at 10:53 PM.
 
Old 12-18-2015, 10:58 PM   #7
like100ninjas
LQ Newbie
 
Registered: Apr 2015
Posts: 24

Rep: Reputation: Disabled
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?
 
Old 12-18-2015, 11:06 PM   #8
tsester
Member
 
Registered: Dec 2011
Distribution: Gentoo
Posts: 46

Original Poster
Rep: Reputation: 2
Quote:
Originally Posted by jpollard View Post
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?)
 
Old 12-18-2015, 11:17 PM   #9
like100ninjas
LQ Newbie
 
Registered: Apr 2015
Posts: 24

Rep: Reputation: Disabled
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?
 
Old 12-19-2015, 04:30 AM   #10
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,654

Rep: Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255
Quote:
Originally Posted by like100ninjas View Post
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.
 
  


Reply

Tags
bash, configuration, csh, exec, login


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Login Shell / Non-Login shell Clarification needed (RHEL 6.3) kingston Linux - Newbie 1 12-07-2012 01:51 AM
how to call a script in a new shell from the current shell Bone11409 Linux - Newbie 2 05-04-2010 05:11 AM
wrong login shell prevent root login cefs99 Linux - Security 4 05-31-2006 09:28 AM
Shell Script call API treotan Programming 1 08-22-2005 11:59 PM
how to put a shell call in a C/C++ program? Hano Programming 8 05-19-2002 03:26 PM


All times are GMT -5. The time now is 07:34 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration