Sponsored Content
Top Forums Shell Programming and Scripting Result of Catching Return Value from Sub_script.sh to Main_script.sh is not as Expected Post 302714507 by duddukuri on Friday 12th of October 2012 09:01:11 AM
Old 10-12-2012
Question Result of Catching Return Value from Sub_script.sh to Main_script.sh is not as Expected

Main_script.sh

Code:
#! /bin/sh

./Sub_script.sh
rc=$?
echo "Return code from Sub_script.sh : $rc"
if [ $rc -eq 991 ]; then
echo "$rc = 991" echo "" exit 1
elif [ $rc -eq 992 ]; then
echo "$rc = 992" echo "" exit 1
elif [ $rc -ne 0 ]; then
echo "$rc = 0" echo "" exit 1
fi echo "Success..." # EOF exit 0

********************

Sub_script.sh
Code:
#! /bin/sh

echo "Hello inside Sub_script.sh"
rc=$?
if [ $rc -eq 0 ]; then
echo "Sub_script.sh rc value : $rc" echo "" exit 991
fi echo "Bye..Sub_script.sh " # EOF exit 0

********************
Main Script Execution Output:
Code:
./Main_script.sh
Hello inside Sub_script.sh
Sub_script.sh rc value : 0

Return code from Sub_script.sh : 223
223 = 0

********************
Expected Main Script Execution Output:
Code:
./Main_script.sh
Hello inside Sub_script.sh
Sub_script.sh rc value : 0

Return code from Sub_script.sh : 991
991 = 0

********************
How to return a custom exit code from Sub_script.sh to Main_script.sh

Thanks a lot in Advance.

-Duddukuri

Last edited by Scrutinizer; 10-15-2012 at 02:05 AM.. Reason: code tags
 

9 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

executing script by cron doesnt give me expected result

Hi frnds... I m facing very irritating problem already waisted my 2 days.. I have a following script..( i am pasting only the main code) ftp -ivn 213.194.40.77 <<FTP user $user $password binary cd $FileDir/out lcd $localpath get $file rename $FileDir/out/$file $FileDir/tmp/$file... (1 Reply)
Discussion started by: clx
1 Replies

2. Programming

Test program not giving expected result

I have five classes. 2 composition classes,1 aggregation class and 1 dependency class.I have coded all the classes but one of my test program is not giving me the expected result.I have the following classes: TimeStamp Interval (composition of 2 TimeStamps) TimeSheet ( aggregation of many... (3 Replies)
Discussion started by: moraks007
3 Replies

3. Shell Programming and Scripting

return value not coming as expected

Hi, We are using a shell script which is called from COBOL program. Here the program works fine till we are using MicroFocus(MF) COBOL 4 and UNIX AIX 5.3. Recently we have upgraded to MicroFocus(MF) COBOL 5.1 but same AIX version. now the shell script not working as expected. The shell... (5 Replies)
Discussion started by: vensk27
5 Replies

4. Shell Programming and Scripting

AWK Looping. How can I get expected result?

Can Anyone help with looping... awk 'FNR==1{i++} {for(k=1; k<=NF; k++) A=$k} # 3 Dimension Array END{ for(i=1;i<=217;i++) # For loop 2nd File 1st and 2nd column x=0;y=0 ... (18 Replies)
Discussion started by: Akshay Hegde
18 Replies

5. Shell Programming and Scripting

Wrong result return from script

Hi Gurus, I need a script to compare two files: sample file like below: list: cde,file4 cde,file5 def,file6 def,file7 def,file8 abc,file1 abc,file2 abc,file3 acd,file9 acd,file10 tmp file1 file2 file3 file4 (12 Replies)
Discussion started by: ken6503
12 Replies

6. UNIX for Dummies Questions & Answers

Why my find return not expected?

root@intel_5500_server:~# find / -name bin -o -name sbin /usr/bin /usr/lib64/pm-utils/bin /usr/lib64/rpm/bin /usr/sbin /bin /sbin root@intel_5500_server:~# which ovs-pki /usr/bin/ovs-pki why below command return nothing root@intel_5500_server:~# find /... (8 Replies)
Discussion started by: yanglei_fage
8 Replies

7. Shell Programming and Scripting

Assigning variable to output gives error with expected result

Hello, I am trying to print out the first string matching query with grep and I need your help. My scenario: Database John F 4433 Street No 88 CA Elisabeth Taylor 7733 Street No 26 ON Jack Nicholson 0133 Green Park No 34 AR John F 2 9399 Southpark No 02D UT test.sh... (6 Replies)
Discussion started by: baris35
6 Replies

8. Shell Programming and Scripting

Not getting expected result

Hi Experts, I have written the below script but its not working as per expectation. My requirement is if this condition ] is satisfied then only check for this condition ] if this also satisfied check for the condition ]. vi p_values.ksh path="/db/ora/files" mode=1 b_days=10... (5 Replies)
Discussion started by: nalu
5 Replies

9. Shell Programming and Scripting

Grep output to file result not as expected

Hi Gurus, I run command grep ABC file1 > file2 against below file. I got all ABC_xxx in one line in file2. I expect to get multiple lines in file2. If I print result in screen, the result is expected. thanks in advance My os is SunOS 5.10 Generic_150400-64 sun4v sparc sun4v ABC_123 XXXXX... (2 Replies)
Discussion started by: green_k
2 Replies
MojoMojo::Schema::Result::Page(3pm)			User Contributed Perl Documentation		       MojoMojo::Schema::Result::Page(3pm)

NAME
MojoMojo::Schema::Result::Page - store pages METHODS
update_content <%args> Create a new content version for this page. %args is each column of MojoMojo::Schema::Result::Content. add_version my $page_version_new = $page->add_version( creator => $user_id, name_orig => $page_new_name, ); Arguments: %replacementdata Returns: The new PageVersion object. Creates a new page version by cloning the latest version (hence pointing to the same content), and replacing its values with data in the replacement hash. Used for renaming pages. tagged_descendants($tag) Return descendants with the given tag, ordered by name. tagged_descendants_by_date Return descendants with the given tag, ordered by creation time, most recent first. descendants @descendants = $page->descendants( [$resultset_page] ); In list context, returns all descendants of this page (no paging), including the page itself. In scalar context, returns the resultset object. If the optional $resultset_page is passed, returns that page from the resultset. descendants_by_date @descendants = $page->descendants_by_date; Like "descendants", but returns pages sorted by the dates of their last content release dates and pages results (20 per page). user_tags($user) Return popular tags for this page used $user. others_tags($user) Return popular tags for this page used by other people than $user. tags_with_counts($user) Return an array of {id, tag, refcount} for the $user's tags. path( [$path] ) TODO Accessor? has_photos Return the number of photos attached to this page. Use for galleries. AUTHOR
Marcus Ramberg <mramberg@cpan.org> LICENSE
This library is free software. You can redistribute it and/or modify it under the same terms as Perl itself. perl v5.14.2 2011-01-12 MojoMojo::Schema::Result::Page(3pm)
All times are GMT -4. The time now is 03:37 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy