I am getting an error of (eval):1 parse error near 'then' when I used zsh's command 'source .zshrc'.
~ source .zshrc
(eval):1: parse error near `then'
this is my .zshrc file:
export ZSH=/Users/chourongqishi/.oh-my-zsh
export PATH=${PATH}:/usr/local/mysql/bin
export PATH=${PATH}:/usr/local/bin
export JAVA_HOME=/usr/libexec/java_home
export
PATH=${PATH}:${JAVA_HOME}:${ANDROID_SDK_ROOT}:${ANDROID_SDK_ROOT}
/platform-tools:${ANDROID_SDK_ROOT}/tools:${JAVA_HOME}:${JAVA_HOME}/bin
export PATH=${PATH}:/Users/chourongqishi/Library/Android/sdk/platform-
tools
export PATH=${PATH}:/Users/chourongqishi/Library/Android/sdk/tools
plugins=(git)
source $ZSH/oh-my-zsh.sh
source ~/.bash_profile
alias cls='clear'
alias -s html=subl
alias -s txt=subl
alias -s java=subl
alias -s xml=subl
The error comes from the source directive which you use. The source directive will execute the files they are provided, within the context of the current script.
You use source ~/.bash_profile. This file is a bash script, you are trying to execute it in zsh.
This is where your problem comes from: ensure you do not import files made for other shell programs.
Related
I am creating an executable to basically do a data guard task
I execute that file from another executable with code
putty.exe -ssh servername -l usernsme -pw password -m C:/auotomation/dgmgrl.sh
and the code in the file is
entdexport ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=/u01/app/oracle/product/12.1.0/NonValidated
export ORACLE_HOSTNAME=servername
export ORACLE_SID=ERIPRD
export PATH=/u01/app/oracle/product/12.1.0/NonValidated/bin:/usr/sbin:/usr/lib64/qt-
3.3/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/oracle/bin
dgmgrl -echo << END
connect /;
show configuration
show database ERIPRD
exit
$SHELL
I have tried adding >> at the end
I can pause my file by adding $SHELL but when inside dgmgrl or sqlplus I am unable to do that.
Without any means of testing it (I neither have a windows machine nor an oracle server) - try this:
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=/u01/app/oracle/product/12.1.0/NonValidated
export ORACLE_HOSTNAME=servername
export ORACLE_SID=ERIPRD
export PATH=/u01/app/oracle/product/12.1.0/NonValidated/bin:/usr/sbin:/usr/lib64/qt-
3.3/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/oracle/bin
dgmgrl -echo << END
connect /;
show configuration
show database ERIPRD
exit
END
bash -l
I assume that the exit is meant to be interpreted by dgmgrl, not the shell?
I am following the direnv wiki on PS1. I have the following relevant entries in my files.
.bashrc
DEFAULT_PS1='\[$(ppwd)\]\u#\h:\w$(__git_ps1 " (%s)")'
# add some more things to DEFAULT_PS1, conditionally
DEFAULT_PS1+='> '
PS1=${CUSTOM_PS1:-$DEFAULT_PS1}
# optional bashrc file extensions
for f in ~/.bashrc_*; do test -s $f && . $f || true; done
eval "$(direnv hook bash)"
.envrc
export KUBECONFIG=~/.config/kube/homelab.yaml
export KUBE_PS1_ENABLED=on
export CUSTOM_PS1='$(kube_ps1) $ '
PATH_add scripts
I have allowed the latest version of the .envrc with direnv allow. However, when changing to the directory, the custom PS1 value is not set, although the values seems to be right
$ cd -
/home/robert/sources/oss/sling-cloud-native
direnv: loading .envrc
direnv: export +CUSTOM_PS1 +KUBE_PS1_ENABLED ~KUBECONFIG ~PATH
$ echo $PS1
\[$(ppwd)\]\u#\h:\w$(__git_ps1 " (%s)")$(kube_ps1)>
$ echo $CUSTOM_PS1
$(kube_ps1) $
I am not sure how the solution in the wiki is supposed to work, as apparently the value of PS1 is set to the DEFAULT_PS1 when the .bashrc file is loaded the first time and is not re-evaluated as part of the direnv hook.
How can I change the value of PS1 using direnv?
The direnv wiki mentions that the author had to "blacklist PS1 as an environment variable that can be changed," mainly because "The core issue is that PS1 is a local variable." So I don't think workarounds that involve using the .envrc file to indirectly modify the PS1 can work.
I had a similar issue with python virtual environments, which I realize is different to your use case, but there is an example in this blog that could be helpful.
Because links can die I reproduce it here:
add the following to ~/.bashrc (me: I tested this with ~/.zshrc and it also works)
show_virtual_env() {
if [[ -n "$VIRTUAL_ENV" && -n "$DIRENV_DIR" ]]; then
echo "($(basename $VIRTUAL_ENV))"
fi
}
export -f show_virtual_env
PS1='$(show_virtual_env)'$PS1
Then source the file again
source ~/.bashrc
The wiki also mentions adding unset PS1 to the .envrc file, which removes any error about direnv: PS1 cannot be exported... and I can confirm that also works with this scenario.
Perhaps you can do something similar; use .envrc to export the environment variables as you are doing, but remove the line export CUSTOM_PS1='$(kube_ps1) $ ' and in your ~/.bashrc make a function that checks if you have set KUBE_PS1_ENABLED and appends '$(kube_ps1) $ ' to PS1 if it is set.
I have installed Pig. But when I am running command to check pig version. It is saying invalid option. I have edited bashrc file.
After doing source .bashrc I am getting following error:
hduser#ubuntu:~$ source .bashrc
bash: export: '=': not a valid identifier
bash: export: '/usr/local/pig': not a valid identifier
bash: export: '=': not a valid identifier
bash: export: 'PATH:/usr/local/pig/bin': not a valid identifier
bash: export: '=': not a valid identifier
bash: export: '/usr/local/hadoop/conf': not a valid identifier
The export statements added to the .bashrc file should not contain whitespaces around =
Edit ~/.bashrc, since the $PATH variable is unset, use absolute paths for the executables.
/usr/bin/vi ~/.bashrc
Add these lines for Pig (taken from the comments) to the bashrc file,
export PIG_HOME=/usr/local/pig-0.15.0
export PATH=$PIG_HOME/bin:$PATH
I am trying to install sqlplus on my mac following the tutorial here: https://tomeuwork.wordpress.com/2014/05/12/how-to-install-oracle-sqlplus-and-oracle-client-in-mac-os/comment-page-1/#comment-6
I have downloaded the two packages (basic and sqlplus) and created all the directories as it says, I moved the necessary files inside the directories.
I created and copied the tnsnames.ora file with the contents:
MYDB=
(DESCRIPTION=
(ADDRESS=
(PROTOCOL=TCP)
(HOST=*********)
(PORT=1521)
)
(CONNECT_DATA=
(SERVER=dedicated)
(SID=MYDB-SID)
) )
And i created the .bash_profile as it says in the tutorial.
But what im stuck on is making the sqlplus run.
typing in sqlplus returns command not found.
in the tutorial it says i should use $ sqlplus username/password#database
where do i get the username and database name from?, I haven't created one yet.
Thanks in advance.
According to your article, you should do the following:
$ vi ~/.bash_profile
Add the following line to the end of the file.
alias sqlplus=’rlwrap sqlplus’
Now reload the .bash_profile:
$ source ~/.bash_profile
Looks like you missed these steps.
You can try to execute:
$rlwrap sqlplus
According to the comments below you do not have sqlplus in the $PATH.
The value of $PATH looks wrong to me: duplicates, quotes.
Option 1
Execute:
export PATH=/Applications/oracle/product/instantclient_64/11.2.0.4.0/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
Then execute in the same console:
$ sqlplus (or $ rlwrap sqlplus)
It will set value only for the current shell. The main idea is to have full path to the sqlplus binary in the $PATH.
Option 2
Modify ~/.bash_profile.
To save as a permanent environment variable edit ~/.bash_profile. There are some details about setting PATH in the source article.
Top down troubleshooting approach
Look for binary - use type
[bbrandt] ~/ $ type sqlplus
sqlplus is aliased to `rlwrap sqlplus'
Where is my binary.. hidden behind an alias, let's unalias
[bbrandt] ~/ $ unalias sqlplus
[bbrandt] ~/ $ type sqlplus
sqlplus is /u01/app/oracle/product/11.2.0/xe/bin/sqlplus
Found it! What happens if I modify my binary search-path?
[bbrandt] ~/ $ echo $PATH
/u01/app/oracle/product/11.2.0/xe/bin:/home/bbrandt/bin:/usr/lib64/ccache:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin
[bbrandt] ~/ $ export PATH=/home/bbrandt/bin:/usr/lib64/ccache:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin
Now, where is my binary?
[bbrandt] ~/ $ type sqlplus
bash: type: sqlplus: not found
[bbrandt] ~/ $
This is where you are... look in your $PATH variable
I have installed pig in my system by using following steps -
first i have downloaded pig-0.14.0.tar.gz
then i have extracted
tar xvzf /home/impadmin/Downloads/pig-0.14.0.tar.gz
sudo mv pig-0.14.0 /usr/local/pig
sudo chown -R hduser:hadoop pig
nano ~/.bashrc
then added the following lines in bashrc file
# PIG binary paths
export PIG_INSTALL="/usr/local/pig"
export PATH="${PATH}:${PIG_INSTALL}/bin"
touch ~/.pigbootup
nano /usr/local/pig/conf/pig.properties
then added the following code in pig.properties
pig.logfile=/home/hduser/hadoop/pig/logs/
after insatllation when i am executing pig version command
then its giving me error -
Cannot locate pig-core-h1.jar. do 'ant jar', and try again
there is a jar file named pig-0.14.0-core-h1.jar so i copied the same file and renamed it as pig-core-h1.jar but still its giving me the same error .
have i done anything wrong during installation?
~/.bashrc should look like this
# PIG binary paths
export PIG_INSTALL="/usr/local/pig"
export PATH="$PATH:$PIG_INSTALL/bin"
No need for the curly brackets
additionally you need to (this or reboot the machine):
$source ~/.bashrc