I have a shell script that declares some variables:
export X=1
export Y=2
and I'd like to be able to do something like this:
. ./path/to/script | command_that_has_access_to_X_and_Y
Basically, source the script somehow, so that the command following the pipe could access those variables. Is such a thing possible?
One of the commands I'd like to run is pg_dump
, and the credentials are in a shell file:
Basically I'm trying to run this:
bash -c "pg_dump \$PRODUCTION_DB --password \$PRODUCTION_PASSWORD --user \$PRODUCTION_USERNAME --host \$PRODUCTION_HOST > #{backup_name}.sql"
script | command "$X" "$Y"
. If you want to push the changes upstream then you will have to use a file.X=$(command "$X")
. Doing that for two variables might require some parsing but it's not that hard