1

I have two shell script files . One is a general file which install something on system and other is a file which processes some steps of installation.

file1: Main Installation file file2: Installation assistance file

I am calling file2 from file1 using

 nohup ./file2.sh $1 </dev/null >../logs/schema.log 2>&1 &
 schema_status=$?
 echo $schema_status

Now because of nohup schema_status value is coming as 0 always.

How do I return a relevant value from file2 to file1 .

In file2, I have added a return statement:

if (condition)
then
   exit 101
else
   exit 102
fi

2 Answers2

0

Please go through the link where a problem similar to your is discussed. It suggest you to export a environment variable in file1.sh and then set this environment variable in file2.sh. By this you will be able return(indirectly) from file2.sh to file1.sh

Pass all variables from one shellscript to another?

Community
  • 1
  • 1
Ashishkumar Singh
  • 3,580
  • 1
  • 23
  • 41
0

When file1 is calling file2 and waits for the result, do not start file2 with nohup. When file2 takes a long time, you can start file1 with nohup.

Walter A
  • 19,067
  • 2
  • 23
  • 43