Thanks for your great Discoveries. Solution provided by Rudi is very easy to implement and it works even with the Perl file reader code I have. Solution provided by Don is also very helpful. However in my case since envfile.txt is being shared across multiple users, I would prefer to make local changes to my script by adding "" in the eval command as in
Also Don I was curious how come in bash the ';' at the end of each line in /tmp/envfile.txt makes it work without "" in eval ? Each entry in my envfile.txt are anyway newline-separated or on a separate line. Isn't that good for bash to understand that each export command in the envfile.txt is a separate export command that i needs to process separately as it is separated by newline. What is the significance of ; as opposed to newline in bash ?
thanks
I do not maintain bash, so I can't say why putting in the semicolon works when a <newline> without the semicolon doesn't work.
If you compare the ksh -xv script trace output to the bash -xv script trace output when running your script, the difference in what the trace of the eval showed made me wonder if a semicolon would make a difference. So I tried it, and it worked. The bash trace output looked like it was executing the command:
after the command substitution, but it didn't export a variable named "export" either.
Even if bash is executing your script (without the double quotes) as:
both export commands clearly have to be evaluated by the the shell in order. And with those two export statements, the result should be the same whether or not the 2nd export is evaluated by the eval or processed as a stand-alone command. Furthermore, if you look at $BASEPATH after the eval completes (with or without the double quotes), you'll see that BASEPATH is set correctly. It just looks like bash executes the 2nd export command before it executes the 1st export command. And, that appears to me to be a bug.
I have a script "abc.sh" in /tmp which has exit 0 as its last line
when I run this script from /tmp/xyz/def.sh script as
. ../abc.sh
then the script executes but the control doesn't return to def.sh script for subsequent commands in def.sh
but if I invoke the abc.sh from inside the... (3 Replies)
hi everyone
i've been reading learning the bash and there is somrthing i don;t
understand what does eval do
i know that it run a command or script twice but i don;t see in
what for cases i can use this
could somebody explain this to me (3 Replies)
Hey all,
I have been using Ksh and in that I am setting Environment variables.
To set Env. Variables I have created my own file "BuildScript.sh" in which i have written :
export CLASSPATH=/somedir/some other dir/file:.
export PATH=/some dir/file:.
But when i am calling this... (4 Replies)
first of all, thanks to all on this board, it has been a huge resource to answer most of my questions!
I am stuck on something that should really be simple, and was looking for some help.. I am using KSH on solaris and working on a script to move containers from server to server. Where i am... (4 Replies)
Hi,
Could any one share the intelligence to track this problem.
I have any array BT_META_36 and it prints properly with contents of array.
# print "BT_META_36=${BT_META_36}"
# BT_META_36=cab3,cab4:HDS:052,07A cab3,cab4:HDS:052,07A
Now I have a BT_META_36 assigned to a variable.... (0 Replies)
Hi!
I wanted to simplify my bash prompt, so I edited my etc/bashrc file. I thought this was the file that would override any other env files. When I opened it, I saw that the way it was setup was not what my prompt looked like, although I forget exactly what was there. But i edited it the way I... (1 Reply)
I am facing a very strange issue. I have script in ksh with #!/bin/ksh as shebang.
This script has function which sets the env variable before running other functions of the script. by
set_up_env()
{
CONFIG_FILE="/opt/app/tools/deepmarking/latestVersion/script/UploadEnv"
if
then
... (7 Replies)
I have tried with the following:
csh -c 'source ~/.cshrc; exec bash' # works perfectly
(cat ~/.cshrc; echo exec bash) | csh # not working
And, using sed, I successfully retrieved the environment variables from ~/.cshrc
sed -rn 's/setenv\s+(\S+)\s+(.*)$/export \1=\2/p' ~/.cshrc
but now... (6 Replies)
Why does dot sourcing of ksh functions behave so differently between AIX, Solaris, and Linux? How can I make Linux behave the way I want in the test I show below?
I have a library of interdependent functions I have developed and use in ksh in AIX. They also run in Solaris. Now I am migrating... (9 Replies)
"Debian 9 64x - LXDE"
I try to source a file from my parent directory:
#!/bin/bash
#source.bash
. ../links.bash but i get "file not found".
I tried . "../links.bash" and . '../links.bash'. I got on all methods the same result.
If i use the absolute path it works, but i don't want to... (4 Replies)