ksh script as a login shell return "no controlling terminal"


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting ksh script as a login shell return "no controlling terminal"
# 1  
Old 07-15-2008
ksh script as a login shell return "no controlling terminal"

I have created a ksh shell script and used it as a login shell for a user.

</etc/passwd>
lramirev:x:111:200:Luis:/export/home/menush:/usr/local/menush/menush

My shell script is like this:
</usr/local/menush/menush>
#!/bin/ksh
#
if [[ -f $HOME/.profile ]]
then
. $HOME/.profile
fi

HOMEPATH=/usr/local/menush
cd $HOMEPATH
export PATH=$PATH:$HOMEPATH

EXITPROMPT="QUIT"

if [[ $(grep $LOGNAME ${HOMEPATH}/denylist | wc -l) -gt 0 ]]
then
. $HOMEPATH/denymenu
else
. $HOMEPATH/mainmenu
fi
do_main_menu

</usr/local/bin/mainmenu>
#!/bin/ksh
do_main_menu ()
{
OPTION="GO"
while [[ "${OPTION}" != "${EXITPROMPT}" ]]
do
print "1 Do first Thing"
print "2 Do second Thing"
print "3 Do third Thing"
print "\nQuit"
cmd_prompt="Press 1, 2, 3 or q>"
print "${cmd_prompt} \c"
read OPTION
case $OPTION in
1) print "Do first Thing"
read
;;
2) print "Do second Thing"
read
;;
3) print "Do third Thing"
read
;;
q|Q) OPTION=${EXITPROMPT}
;;
*) print "Select option from menu"
OPTION="GO"
read
;;
esac
do
}

</usr/local/bin/denymenu>
#!/bin/ksh
do_main_menu ()
{
OPTION="GO"
while [[ "${OPTION}" != "${EXITPROMPT}" ]]
do
print "\nQuit"
cmd_prompt="Press q>"
print "${cmd_prompt} \c"
read OPTION
case $OPTION in
q|Q) OPTION=${EXITPROMPT}
;;
*) print "Select option from menu"
OPTION="GO"
read
;;
esac
do
}

Every thing work fine I can create my users, they can login and do they're three things only in the menu. I have "trap" signals 2, 5 and 9 and they can't go out of the script. The bad thing here is that on "Do third Thing" they need to type a file name and the system will process the file name. In order to have the file available to the system shell script they need to be able to upload the file to the server. I can't login with user lramirev using FTP or SCP to upload a file to me processed.


This is the output from SCP
>scp motd lramirev@mtyweb02g2:/export/home/menush
Password:
ps: no controlling terminal
stty: : Invalid argument

Thsi is the output for FTP:
> ftp mtyweb02g2
Connected to mtyweb02g2.
220 mtyweb02g0 FTP server ready.
Name (mtyweb02g2:lramirev): lramirev
331 Password required for lramirev.
Password:
530 Login incorrect.
Login failed.
ftp>

Password is correct typed, I can telnet to the server or ssh to it and will get the menu to run processes.

Does any one knows how can I provide a upload facility for this type of users? I can try two thing but would like not to do it.
1. Have the user with /bin/bash as login shell and user .profile to load menush but that may give me a problem becuase I dont want users to scape out of the menu.
3. Try to do a TFTP upload. I wouldn't like to because it is very unsafe. I can olway TCP_Wrap FTP but TFTP as far as I know is imposible to secure.

Please send some light to my yellow road.

My best regards.
Luis Ramirez
Unix Systems implementation
# 2  
Old 07-15-2008
You probably need to add your script to /etc/shells as ftpd and sshd check this for valid shells before granting access.
# 3  
Old 07-15-2008
You probaby need to add /usr/local/menush/menush to /etc/shells to get ftp working. This should be documented in "man ftpd".
# 4  
Old 07-15-2008
simulpost! Smilie
# 5  
Old 07-15-2008
Great minds think alike... and concurrently too. Smilie
# 6  
Old 07-15-2008
Maybe I had to add the info before, but I'm using Solaris 10 and I don't have /etc/shells. I have look into the man pages fo FTPD and SSHD and they don't relate to /etc/shells. Do you have any other idea?

Thanks in advance
Luis Ramirez
# 7  
Old 07-15-2008
You can create it, you may want to include the default list of shells as well, from man shells (not directly, I copied it from another post elsewhere):

from man shells

====
The following default shells are used by utilities:
/bin/bash, /bin/csh, /bin/jsh, /bin/ksh, /bin/pfcsh,
/bin/pfksh, /bin/pfsh, /bin/sh, /bin/tcsh, /bin/zsh,
/sbin/jsh, /sbin/sh, /usr/bin/bash, /usr/bin/csh,
/usr/bin/jsh, /usr/bin/ksh, /usr/bin/pfcsh, /usr/bin/pfksh,
/usr/bin/pfsh, and /usr/bin/sh, /usr/bin/tcsh, /usr/bin/zsh.
Note that /etc/shells overrides the default list.
====
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Bash script - Print an ascii file using specific font "Latin Modern Mono 12" "regular" "9"

Hello. System : opensuse leap 42.3 I have a bash script that build a text file. I would like the last command doing : print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt where : print_cmd ::= some printing... (1 Reply)
Discussion started by: jcdole
1 Replies

2. Red Hat

"rhgb quiet" controlling the display of commands in single user mode ?"rhgb quiet" controlling the d

Why does removing "rhgb quiet" from the kernel boot parameters control whether or not the commands I enter are displayed in single user mode ? For instance, if I do not remove "rhgb quiet", when I am in single user mode, whatever command I type will not be displayed on the screen. The... (0 Replies)
Discussion started by: Hijanoqu
0 Replies

3. Shell Programming and Scripting

Shell script using expect to login to couple of remote servers and read "crontab -l"

I need a shell script using expect to login to couple of remote servers and read "crontab -l -u <username>" & "cat /etc/rc.local" & "df -h" and able to create output into a file saved locally with hostname.crontab & hostname.rc.local & disk.status. I can supply a file as list of hostname or IP... (4 Replies)
Discussion started by: jaipsharma
4 Replies

4. Shell Programming and Scripting

ksh script that echo " please insert your name " and store the output to a login.log file.

Hello All Nice to meet you all here in this forum, it's my 1rst time here i'm asking about a little issue that i face i added a ksh script that echo " please insert your name " and store the output to a login.log file. the script is working fine with normal telnet but Xstart is not working... (8 Replies)
Discussion started by: islam.said
8 Replies

5. UNIX for Dummies Questions & Answers

how to install "source" command!/ broken "login.cl"!

Hello, I am new to this forums and this is my first "asking help" message! i have 2 problems: 1- for unknown reasons the "source" command is not avalable in my system (UBUNTU). i can't either see it in my bin directory! 2- again for unknown reasons the "login.cl" file in the home... (0 Replies)
Discussion started by: astrosona
0 Replies

6. AIX

"ksh -" as login shell bypassing .profile

Hi all, I am currently trying to tell /bin/ksh to behave like a login shell. I am invoking it from an interactive shell. In the documentation is stated, that calling it with exec ksh - it should behave like a login shell, work 1st on /etc/profile, ~/.profile and so on. I tried that with... (0 Replies)
Discussion started by: zaxxon
0 Replies

7. AIX

"too big" and "not enough memory" errors in shell script

Hi, This is odd, however here goes. There are several shell scripts that run in our production environment AIX 595 LPAR m/c, which has sufficient memory 14GB (physical memory) and horsepower 5CPUs. However from time to time we get the following errors in these shell scripts. The time when these... (11 Replies)
Discussion started by: jerardfjay
11 Replies

8. HP-UX

script running with "ksh" dumping core but not with "sh"

Hi, I have small script written in korn shell. When it is called from different script, its dumping core, but no core dump when we run it standalone. And its not dumping core if we run the script using "/bin/sh" instead of "ksh" Can some body please help me how to resolve this issue. ... (9 Replies)
Discussion started by: simhe02
9 Replies

9. Shell Programming and Scripting

How to include RETURN KEY with Background process "&" in Shell Script

Hello All, I am a newbie in Shell script programming, and maybe you can help me with my query. I need to write a shell script (mntServer.ksh) that will start a background process and also to be able to run another script. The mntServer.ksh script contains: #!/bin/ksh... (1 Reply)
Discussion started by: racbern
1 Replies

10. UNIX for Dummies Questions & Answers

No utpmx entry: you must exec "login" from lowest level "shell"

Hi I have installed solaris 10 on an intel machine. Logged in as root. In CDE, i open terminal session, type login alex (normal user account) and password and i get this message No utpmx entry: you must exec "login" from lowest level "shell" :confused: What i want is: open various... (0 Replies)
Discussion started by: peterpan
0 Replies
Login or Register to Ask a Question