2

I'm looking for a way to accomplish this in a single statement:

./perlscript.pl ./inputFile "some option" > temp.sh; source temp.sh; rm -f temp.sh

temp.sh does

export ENV_VAR="some value"

and after the above commands echo $ENV_VAR reports some value.

I've tried

./perlscript.pl ./inputFile "some option" | source /dev/stdin

and the script runs, but the source doesn't seem to have worked; echo $ENV_VAR shows nothing. I feel like this is very close, but I've run out of ideas.

Any ideas?

1
  • 1
    source is basically "read a file and eval it"; how about eval "$(perl etc)" Commented Apr 10, 2014 at 17:37

1 Answer 1

6

You can use process substitution like this:

source <(./perlscript.pl inputFile "some option")
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.