Problem in Unix script to exit from Putty


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Problem in Unix script to exit from Putty
# 1  
Old 01-13-2012
Problem in Unix script to exit from Putty

We have a requirement where in the user needs to select a option 4 from the menu and the putty window should be closed.I tried giving exit 0 ;; and this is only exiting from the script menu and showing back the prompt.Is there a way for this.

Last edited by vbe; 01-13-2012 at 09:52 AM..
# 2  
Old 01-13-2012
try
Code:
env | grep SSH_CLIENT | awk ' { print $2 } '

that should return the PID of ssh client session.
Then maybe you can kill the session by killing that PID.
# 3  
Old 01-13-2012
also execute your script this way (dot space <yourscript>) like :
Code:
. ./yourscript

here is a quick example you can try :
Code:
$ echo "exit" >mytst
$ chmod +x mytst
$ cat mytst
exit
$ ./mytst
$ sh ./mytst
$ . ./mytst

The last command will exit the terminal session you are in




Also note that the persistence of PuTTY windows can be tweaked in PuTTY configuration :
Menu : "Session"
Frame : "Close window on exit"
-Always
-Never
-Close on exit

... just choose the option you need

Last edited by ctsgnb; 01-13-2012 at 10:08 AM..
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Make expect exit the UNIX script in erreneous condition

Hi, I am writing a menu driven program using shell script. THe script will be collecting data by logging into the other servers and bringing back the data to home server to process it and accordingly issue commands. TO automate commands execution , I am using expect script. However I am not able... (5 Replies)
Discussion started by: ashima jain
5 Replies

2. Windows & DOS: Issues & Discussions

Connecting to UNIX from Windows without using putty

Hi Is there any command which we can try connecting unix from windows without using any third party tool. Thanks in advance KVB (9 Replies)
Discussion started by: bikky6
9 Replies

3. Shell Programming and Scripting

How to exit a shell script if a unix command does not return any value for 10 seconds?

Hi, Can anyone help me how to exit a shell script if a unix command inside does not return any value for 10 seconds? The scenarios is like this. I want to login to a application using shell script where the connection string is mentioned.but suppose this connection string is not... (10 Replies)
Discussion started by: arijitsaha
10 Replies

4. Shell Programming and Scripting

Exit code from piping in unix shell script

Hi , I have following code in my shell script : "$TS_BIN/tranfrmr" "${TS_SETTINGS}/tranfrmr_p1.stx" "${TS_LOGS}/tranfrmr_p1.err" | ( "$TS_BIN/cusparse" "${TS_SETTINGS}/cusparse_p2.stx" "${TS_LOGS}/cusparse_p2.err" | ( "$TS_BIN/tsqsort" "${TS_SETTINGS}/srtforpm_p3.stx"... (8 Replies)
Discussion started by: sonu_pal
8 Replies

5. UNIX for Advanced & Expert Users

Unix user with root power problem in to login in putty

Hello, I created a user in my AIX 5.3 system and i modified /etc/passwd file in and assigned this user the uid=0 like root user. The problem is that when this user log into the system through putty it asks for root password instead of the user password. As a result of this, if i reset the... (4 Replies)
Discussion started by: omonoiatis9
4 Replies

6. Shell Programming and Scripting

PUTTY via UNIX script

HELP!!!! I want to execute a PUTTY telnet connection via UNIX script??? Any help please?? Thanks (1 Reply)
Discussion started by: tontal
1 Replies

7. Shell Programming and Scripting

problem in exit status of the command in a shell script-FTP

Hi All, I have developed below script for FTP a file from unix machine to another machine. ftpToABC () { USER='xyz' PASSWD='abc' echo "open xx.yy.zbx.aaa user $USER $PASSWD binary echo "put $1 abc.txt" >> /home/tmp/ftp.$$ echo "quit" >> /home/tmp/ftp.$$ ftp -ivn <... (3 Replies)
Discussion started by: RSC1985
3 Replies

8. UNIX for Dummies Questions & Answers

Problem with putty and password

I am using putty to ssh into my linux machine, I followed the steps to create password less authentication. 1. generated both private and public key 2. copied the public key over to the ~/.ssh/authorized_keys file 3. loaded Private key with pagent (when it didnt work i used Auth in Putty to... (2 Replies)
Discussion started by: bensen
2 Replies

9. UNIX for Dummies Questions & Answers

reg putty problem

Hi, i am using PUTTY 0.51 release for connecting the Red hate linux box in SSH mode. its working fine but i can't able to scoll the scoll bar using scroll wheel inthe mouse. please suggest me how to solve it. thanks in advance. thanks and regards, ilayans (2 Replies)
Discussion started by: ilayans
2 Replies

10. UNIX for Dummies Questions & Answers

changing shells in unix (im using putty)

hi. im new here. im taking a UNIX OS class and im in need of some help how do i change my shell in UNIX? for homework i need to edit the tcshrc file (to include aliases) in my home directory but its not there. so i think switching shells will create the file. am i correct? I'm using PuTTy.... (1 Reply)
Discussion started by: alpha_centauri
1 Replies
Login or Register to Ask a Question