The Kraken
The Kraken

Reputation: 3158

How to use return value of one program as input for another?

I know that I can use pipes to set the output stream of one program to input for another:

bigNumber | factors

But what if I want to simply feed the returned value from bigNumber's main function as factors's input rather than what bigNumber echos to the output stream?

Upvotes: 2

Views: 68

Answers (2)

alex94puchades
alex94puchades

Reputation: 153

The error code returned by the last executed program is available in the $? shell variable

Upvotes: 1

wallyk
wallyk

Reputation: 57794

Try this:

bigNumber
echo $? | factors

Most Unix/Linux shells make the exit value available in the variable $?.

Upvotes: 2

Related Questions