Posts

Showing posts with the label Unix

Can I Export A Variable To The Environment From A Bash Script Without Sourcing It?

Answer : Is there any way to access to the $VAR by just executing export.bash without sourcing it ? Quick answer: No. But there are several possible workarounds. The most obvious one, which you've already mentioned, is to use source or . to execute the script in the context of the calling shell: $ cat set-vars1.sh export FOO=BAR $ . set-vars1.sh $ echo $FOO BAR Another way is to have the script, rather than setting an environment variable, print commands that will set the environment variable: $ cat set-vars2.sh #!/bin/bash echo export FOO=BAR $ eval "$(./set-vars2.sh)" $ echo "$FOO" BAR A third approach is to have a script that sets your environment variable(s) internally and then invokes a specified command with that environment: $ cat set-vars3.sh #!/bin/bash export FOO=BAR exec "$@" $ ./set-vars3.sh printenv | grep FOO FOO=BAR This last approach can be quite useful, though it's inconvenient for interactive use sin...

Chown Illegal Group Name (mac Os X)

Answer : Try using just the owner if no group. sudo chown -R user: /usr/local/var/log/couchdb illegal group name actually means that the group you're specifying (the couchdb after the colon -- the first couchdb is the user) doesn't exist. You need to either create the group, stop specifying a group, or specify a group that exists.

Capturing STDERR And STDOUT To File Using Tee

Answer : The latter; it makes sure STDOUT and STDERR of the original command go to the same fd, then feeds them jointly into tee. In the former case, it's the STDERR of the tee command that you'd be joining with its STDOUT.