0

I have to get "export" lines from a remote file on another server, then set the current sh session env dynamically.

However, echo with export doesn't seem to work.

echo `export CONFIGA=configurationA`

I try to create this script as generic and as simple as possible, cause there are many export statements from the remote file, and not all is used. The ones I need will be determined by certain patterns, but the number of those statements is also dynamic.

Now I wonder if this can be done in ksh script, but I have no other options at the moment.

1 Answer 1

0

There's probably a more elegant way to do this, but you could pull your desired variables from that remote file into a local temporary file:

file=/tmp/tempfile.$RANDOM ## AIX doesn't come with mktemp
> $file || echo Failed to pick a good tempfile name
grep "export CONFIG.=" some-file > $file

Then use the . builtin to read that file:

. $file

and of course, clean up:

rm $file
1
  • Beautiful! Thanks Jeff, and thanks for fixing the title.
    – wez
    Jun 7, 2016 at 1:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .