Caporegime
To clarify..
I'm trying to take the output from a command, and then execute that output as a command in and of it self.
I.e.:
To be more exact in what I am doing, I am running ssh-agent in my .bashrc and will be auto-adding my identities to the agent, but in order to do so I have to have the env variable SSH_AUTH_SOCK set with the location of the sock file that ssh-add will need to talk to.
Helpfully, the output of ssh-agent is similar to:
So far I've got this:
But I'd like to do this without use of the file.
I've tried using exec and command, neither seem to run in the same env as the current env - i.e. the env vars don't change from what they were before the script ran.
I'm trying to take the output from a command, and then execute that output as a command in and of it self.
I.e.:
Code:
commandA | <do something here to execute output as a command in the current environment>
To be more exact in what I am doing, I am running ssh-agent in my .bashrc and will be auto-adding my identities to the agent, but in order to do so I have to have the env variable SSH_AUTH_SOCK set with the location of the sock file that ssh-add will need to talk to.
Helpfully, the output of ssh-agent is similar to:
Code:
SSH_AUTH_SOCK=/tmp/ssh-DVbGwA4636/agent.4636; export SSH_AUTH_SOCK;
SSH_AGENT_PID=10084; export SSH_AGENT_PID;
echo Agent pid 10084;
So far I've got this:
Code:
#kill any existing ssh-agents so we can start our own and locate sock file
ps -ef | grep ssh-agent | awk '{print $2}' | xargs kill > /dev/null
ssh-agent | sed "s/^echo/#echo" > /tmp/sshstuff
chmod 600 /tmp/sshstuff
. /tmp/sshstuff
ssh-add
I've tried using exec and command, neither seem to run in the same env as the current env - i.e. the env vars don't change from what they were before the script ran.