1753816 Members
8767 Online
108805 Solutions
New Discussion юеВ

Help Needed for Script

 
SOLVED
Go to solution
Karthick K S
Frequent Advisor

Help Needed for Script

Hi,

I write a one script for quit the application , if i quit the db it should comeout from telnet sessions itself and also CTRL-C should not work because only quit only can quit the session

below the script i tried but if i quit its going to $ prompt and not comeout from telnet session

pls help anyone

dbcheck()
{
if [ $DB123 = "quit" ]
then
clear
exit 0
else
getdb
fi
}

getdb()
{
clear
echo "\n\n\n\n\n
Enter the db name you wish to connect to \n or quit to exit : \c"
read DB123

dbcheck
}

getdb


17 REPLIES 17
Arunvijai_4
Honored Contributor

Re: Help Needed for Script

Hi Karthik,

You can try two options,

#1. Try logout, it will logout from script shell.

#2. Create an alias for it, just like "./myscript.sh; exit"

-Arun
"A ship in the harbor is safe, but that is not what ships are built for"
Karthick K S
Frequent Advisor

Re: Help Needed for Script

Hi Arun,

Can you give some example how to do
RAC_1
Honored Contributor

Re: Help Needed for Script

To get out of telnet session you need to put in "exit" command.

To disable operation of ^c, you need to set the trap to ignore ^c.
trep '' 3
3 is interrupt signal.
There is no substitute to HARDWORK
RAC_1
Honored Contributor

Re: Help Needed for Script

dbcheck()
{
if [ $DB123 = "quit" ]
then
clear
break
exit 0
else
getdb
fi
}
logout # logout is quit is entered.

getdb()
{
trap '' 3 # to ignore the ^c
clear
echo "\n\n\n\n\n
Enter the db name you wish to connect to \n or quit to exit : \c"
read DB123

dbcheck
}

getdb
There is no substitute to HARDWORK
Arunvijai_4
Honored Contributor

Re: Help Needed for Script

Karthick K S
Frequent Advisor

Re: Help Needed for Script

Hi RAC,

Trap is not working pls help me if u hv example pls tell
RAC_1
Honored Contributor
Solution

Re: Help Needed for Script

change trap command as follows and check.
trap "" 1 2 3 # to ignore trap signals 1 2 3
There is no substitute to HARDWORK
Karthick K S
Frequent Advisor

Re: Help Needed for Script

Thanks RAC,

Trap is working now my script is disabled the CTRL-C but how i should comeout from current telnet session thro' script
Arunvijai_4
Honored Contributor

Re: Help Needed for Script

Hi Karthik,

You need to logout from the shell or kill it's PPID within the script. Take a look at the link which i have posted earlier on how to accomplish this.

-Arun
"A ship in the harbor is safe, but that is not what ships are built for"