LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   exit from subshell (https://www.linuxquestions.org/questions/linux-newbie-8/exit-from-subshell-803213/)

ravibhure 04-21-2010 01:47 AM

exit from subshell
 
Hi,
I have wrote one subshell script to use ftp in my env, but I am not able to exit from the subshell loop even I use function exit here, anybody help me to exit from the subshell, I am not sure but if we use array into loop it will exit but how I can use.

#!/bin/bash
if [ "$#" != "1" ]
then
echo
echo "Usage: $0 <my group> "
echo "Example: $0 files "
echo
exit 1
fi
exit() {
echo ByeBye
break
}
while :
do
echo -n "MYFTP> " | tee -a $MYFTP_LOG_FILE
read myftp_cmd
eval $myftp_cmd 2>&1 | tee -a $MYFTP_LOG_FILE
echo
done

grail 04-21-2010 02:02 AM

I am not sure where your confusion is?
You created an infinite loop with
Quote:

while :
and never use anything within the loop to stop looping.

ravibhure 04-21-2010 02:08 AM

Yes Grail,
I want to stop looping the subshell when type 'exit' command on subshell promp, so How can I handle the code regarding to exit or stop the looping.


All times are GMT -5. The time now is 02:13 AM.