It seems like you want to save a variable, exported from a remote script, which is invoked over an ssh session.
If you are on the same server when you export a variable, this works fine but but you can't simply export a variable on a remote shell and save it because you are working with two separate login environments.
A couple ways to do this, although I can think of a few more involved ones:
1) have ./quick
on the remote print the value of the variable you want to save. You can save what's printed on the local side during the run:
mylocal=$(ssh -o StrictHostKeyChecking=no -q oracle@$database_server_ip "cd $script_loc && . ./quick")
A word of caution here - an error message or something unexpected at runtime can end up going into mylocal
if a runtime error occurs. This can result in unexpected things in your variable. Often, you can check the result code of the ssh
command to see if the remote exited cleanly (check the bash variable $?
right after the ssh run). Usually this should be a 0
if everything ran fine which suggests you can trust the value in mylocal
. If quick
issues an exit 2
in it's code, $?
should contain a 2 on the local side after ssh returns.
2) do some extra error checking in the quick
script and handle any errors there to make sure you can debug runtime issues and only spit out the value of the variable you want to save locally (mentioned in a comment above). You would still invoke your ssh
run the same way, you would just be doing some extra checking to terminate with an error code (exit 2
) on purpose so you can check $?
locally for errors. If $?
is a 0
, you know things ran fine and your local variable is valid.