Visit Our UNIX and Linux User Community


Strange errors with shell scripts..plzz help


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Strange errors with shell scripts..plzz help
# 1  
Old 06-06-2011
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:
Code:
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..

Last edited by vbe; 06-06-2011 at 11:59 AM.. Reason: code tags are to be used when inserting code in post
# 2  
Old 06-06-2011
The use of .(dot to source) <shell script> is specifically used to initialize / update your environment and is called "source".
This User Gave Thanks to vbe For This Post:
# 3  
Old 06-06-2011
This explains in a bit detail.

4 Ways of Executing a Shell Script in UNIX / Linux (link removed)
This User Gave Thanks to panyam For This Post:
# 4  
Old 06-06-2011
Hi alll ..

Thanks for the replies..

why the following script is creating log file with ""?"" at the end.
Code:
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?
Moderator's Comments:
Mod Comment
Please use code tags when posting data and code samples!

Last edited by vgersh99; 06-06-2011 at 01:08 PM.. Reason: once again - please use code tags!

Previous Thread | Next Thread
Test Your Knowledge in Computers #742
Difficulty: Medium
XL Fortran is the name of an open source Fortran compiler for IBM-supported environments, including Linux for big-endian distributions and AIX.
True or False?

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell Script..plzz help

Hi all, if any body could help me out to automate the unix script for finding some particualar files which are based on dates like see every day i need check the TXT files which are being in processed and Sequential order based on dates For Example: files name starts at... (12 Replies)
Discussion started by: krux_rap
12 Replies

2. Shell Programming and Scripting

Not able to solve these questions plzz help

1.Display a list of /usr/share/doc subdirectories containing information about shells.How many README files do these subdirectories contain? Don't count anything in the form of "README.a_string". 2.Make a list of files in your home directory that were changed less that 10 hours ago, using grep,... (2 Replies)
Discussion started by: cynosure2009
2 Replies

3. Shell Programming and Scripting

Strange SIGINT propagation between Parent/Child sh scripts

Good day, I am trying to add signal handling capabilities to some of my scripts. Unfortunately, I am having some difficulty with the manner in which signals are propagated between parent/child processes. Consider the following example: I have the following "parent" script: #!/usr/bin/sh... (5 Replies)
Discussion started by: danie.ludick
5 Replies

4. Shell Programming and Scripting

I need to add something to a file, plzz help

The first step for you to create the script to change “JAVA_OPTS” variable definition as follows: Original line: JAVA_OPTS="-Dname=$JAVA_NAME -Xmx$JVM_MAX -DAGENT_HOME=$RT_HOME -DINSTALL_DIR=$RT_HOME -Djavax.net.ssl.keyStore=$RT_HOME/conf/client.keystore ... (3 Replies)
Discussion started by: asirohi
3 Replies

5. UNIX for Advanced & Expert Users

strange "No such file or directory" errors on NFS volumes

we're seeing very strange "No such file or directory" errors on NFS volumes on one of our suse servers - can anyone please help? we're seeing it for both our NetApp NAS Device and one of our Solaris NFS servers too Here is what we're seeing: stg-backup:~ # cd /rmt/sge stg-backup:/rmt/sge... (3 Replies)
Discussion started by: fishsponge
3 Replies

6. Shell Programming and Scripting

shell script & sqlplus "plzz help"

hi friends, i m tryin to load data from one set of table to other i have sql procedure al ready for it..! i m going to load the procedure only if data in one of my table for example table "landing " have 10 records each attribute of this table is file_name status date ... (2 Replies)
Discussion started by: kulbir
2 Replies

7. UNIX for Dummies Questions & Answers

Handling Errors in Shell Scripts

I have a shell script, which calls a load script to load a database. How can i handle errors in Unix(similar to 'error level' in Batch scripts)? I am trying to use 'mailx' to send a Success/failure message based on the error level returned by the load script. I have already used an error log... (2 Replies)
Discussion started by: sarsani
2 Replies

8. Shell Programming and Scripting

How to find out Errors in FTP Scripts

Hi Please let me know is there any way through which I can find out errors & do debugging in FTP scripts. Thanks Sourabh TCS (1 Reply)
Discussion started by: sourabhshakya
1 Replies

9. UNIX for Dummies Questions & Answers

problem with GREP, help plzz

I just want the output of this command to be stored in a variable like, str = `grep Application.dbName serverdata/ServerProp.txt` but while executing it says like, str : startup 11: not found, where startup is the script name. but while running the command alone like, grep... (2 Replies)
Discussion started by: cs_sakthi
2 Replies

Featured Tech Videos