Strange errors with shell scripts..plzz help

Hi all...

Please help me with this questions.
I am not good at shell scripting.

1) It seems like there are many ways that we can run the shell scripts.
what is the difference between each one?
i)./shell_script.sh
ii).(space)./ shell_script.sh
iii)sh shell_script.sh
iv).(space)shell_script.sh
is there any difference in executing the shell scripts in the above ways?
**** I am getting strange errors when i am executing the shell scripts *****

2) one of my shell script (very simple one).
It is working sometimes and it is throwing error some times.
The follwoing script works fine when i run it ./shell_script.sh
and it throws error when i run it like .(space)./shell_script.sh.
(error ksh: ./shell_script.sh[9]: here document `EOF' unclosed)

shell script:

export TEST_VAR="HELLO WORLD"
sqlplus username/password@database << EOF > /lhome/xrmadm/bin/test1.log
set serveroutput on size 200000
whenever sqlerror continue
set echo on
exec dbms_output.put_line('$TEST_VAR');
exit;
EOF

The above script is creating a log file like this test.log? (i dont why that ""?"" is coming after running)

3)I have another script which is working
if i run it .(space)./shell_script.sh

Thanks in advance...please help me with the above questions..

The use of .(dot to source) <shell script> is specifically used to initialize / update your environment and is called "source".

1 Like

This explains in a bit detail.

4 Ways of Executing a Shell Script in UNIX / Linux (link removed)

1 Like

Hi alll ..

Thanks for the replies..

why the following script is creating log file with ""?"" at the end.

export TEST_VAR="HELLO WORLD"
sqlplus username/password@database << EOF > /lhome/xrmadm/bin/test1.log
set serveroutput on size 200000
whenever sqlerror continue
set echo on
exec dbms_output.put_line('$TEST_VAR');
exit;
EOF

It is creating ""test1.log?"" file instead of ""test1.log""

is there any thing wrong that i am doing?