korn shellscript execution context - exit statement


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers korn shellscript execution context - exit statement
# 1  
Old 03-30-2005
korn shellscript execution context - exit statement

Hi all,

Could someone please explain to me the shell invocation process when running a script. How do I stop the shell from logging out when it reaches an exit statement in the script?

Code:
        if [ $? -ne 0 ]; then
                echo 'Failed to copy ${FILE}.fmx to ${J2_HOME}/dev/rsc'
                exit 1
        fi

This is inside a function called publish_form. I want to execute the command from the command line like publish_form form1.fmx but every time it hits the exit statement in the function def, the shell exits and my unix session ends.

Help is appreciated?

Thanks.

Rich.
# 2  
Old 03-30-2005
I don't exactly understand what you're doing, but try changing the "exit 1" to "return 1".
# 3  
Old 03-30-2005
remove 'exit' from the script and try.
# 4  
Old 03-30-2005
Quote:
Originally Posted by Perderabo
I don't exactly understand what you're doing, but try changing the "exit 1" to "return 1".
Thanks that's solved it.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How to use exit status of two commands in if statement ?

I am trying to write a shell script, which looks like #!/usr/bin/env bash #set -e RED="`tput setaf 1`" GREEN="`tput setaf 2`" BLUE="`tput setaf 4`" NORM="`tput sgr0`" pushd ${MY_GIT_TOP}/body/Ue/test >/dev/null #MY_GIT_TOP is set my by gitenv make test_trinity_svp pushd... (8 Replies)
Discussion started by: Sekhar419
8 Replies

2. Shell Programming and Scripting

Korn shell script - SQL statement challenges

Hi scripting experts. I have some coding challenges that I'm hoping you can help me out. I have one file#1 that contains the following sql statement that spans over multiple lines: sql Select /*+ use_has(a,b) */ * from customer a, customer_address b where a.id = b.id... (1 Reply)
Discussion started by: pchang
1 Replies

3. UNIX for Dummies Questions & Answers

[Solved] Korn Shell execution

There are two Korn Shell scripts : script_1.ksh ( located in /home/dir1 ) script_2.ksh ( located in /home/dir2 ) Content of script_2.ksh is #!/usr/bin/ksh echo "Hello world.." The script_2.ksh is called from within script_1.ksh using the following command : ./home/dir2/script_2.ksh but... (7 Replies)
Discussion started by: kumarjt
7 Replies

4. Shell Programming and Scripting

Execution problem with the FTP shellscript

Hi Friends I am new to the shell script and i have a script which will connect to server enviornment which will read a file and will FTP to an another server location. But while executing this script FTP transfer is not occuring. But when I enter in FTP mode I am able to transfer the file... (5 Replies)
Discussion started by: Kannannair
5 Replies

5. Shell Programming and Scripting

ctrl+c statement in shellscript

Hi, I run the below commands manually without shellscript. After that i enter one tuple contains some 4-5 fields . sbc -p 40000 enq siOrInput id parentid sybol avg quantity price after entering the first command i pass the tuples to that command. It automatically... (0 Replies)
Discussion started by: aish11
0 Replies

6. UNIX for Dummies Questions & Answers

If statement for substring within string (korn)

Hi all, Just looking for a simple if statement that searches for a substring within a varaible, and then performs some function. Problem is that I need it to work in Korn shell $var = *string* does not work in Korn i="xxxxxx00.00yyyyy.zzzzz" want to find 00.00 (2 Replies)
Discussion started by: jgrosecl
2 Replies

7. UNIX for Dummies Questions & Answers

Using 'diff' exit status in an if statement

is there a way to compare two files using diff (ex: diff 1.txt 2.txt) in an if statement? I read that the exit status of diff is 0 if the files contain the same content. 1 if they're different. So what I am attempting is basically: if ; then echo "they're the same" else ... (2 Replies)
Discussion started by: SoVi3t
2 Replies

8. Shell Programming and Scripting

Korn Shell Script help required during execution...

Hi, The following Korne Shell script does not give any syntax errors but the following while running. Request you to please let me know, how can I define the variables viz.:- listDbs and getkey here, inorder to remove the error. 1) $ ksh -n setAlias $ 2) $ ksh -x setAlias +... (1 Reply)
Discussion started by: marconi
1 Replies

9. UNIX for Dummies Questions & Answers

korn shell to bash - statement not working

Everything else seems to be working, but this isn't. Is it the "cat..." that is wrong of the condition? Thanks. cat tc_result.txt | while read LINE do if then let "files_run += 1"; echo "inside the if loop" # save current filetype case $LINE... (5 Replies)
Discussion started by: brdholman
5 Replies

10. UNIX for Advanced & Expert Users

Exit codes in Korn shell

Hi, Can anyone give me the explanation for the exit codes 1 and 127 returned from Korn shell. Thanks in advance. (2 Replies)
Discussion started by: miltony
2 Replies
Login or Register to Ask a Question