Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to capture the output of one shell script into other in unix

Tags:

shell

unix

sed

awk

I am running one shell script run_sftp.sh whose output will be either "done" or "failed" and I am calling this script into another script which will execute some command if run_sftp.sh output is "done"

If [ Output(run_sftp.sh) = 'done' ] then
  echo "run"
else
  "Stop running"
fi 

This is the algorithm. Please suggest.

like image 470
Pooja25 Avatar asked Dec 04 '25 03:12

Pooja25


1 Answers

like this?

retval=$(path/to/run_sftp.sh)

now you have done/failed in var retval. you can do your if check with your logic.

like image 142
Kent Avatar answered Dec 06 '25 17:12

Kent



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!