I included a # (pound sign) in a script believing it was to "comment the line", but it executed the line anyway

Posted on 2006-04-03
Last Modified: 2013-12-27
I had a script to shutdown the database.  This script runs in the cron Sundays.
The cron somehow did not execute the script.
I thought the script has something wrong, and started commenting out the  following lines in the script with a # (pound sign).
# lsnrctl stop
# shutdown immediate << EOF

Then I added a:
spool test.log
 select count (*) from dba_data_files;
spool off;

I tried to run it from the cron but it did not run, so I tried to run it manually, and it started to shutdown the database.  The listener was not stopped.
Why the pound sign was respected in a OS command, but the command inside the Sqlplus was executed regardless of the pound sign in fron of the line.

This was done with the oracle user which has this shell in the /etc/passwd:

Question by:LindaC
    LVL 6

    Accepted Solution

    If you're running part of the script in sql plus, then the comment must begin with a "--" (double dash) instead of a #.
    LVL 7

    Expert Comment

    if bpeterse's comment wasn't the solution, then please post your script. The line
    shutdown immediate << EOF
    makes no sense for me, since shutdown IMHO is not a command expecting more input. So I assume, that you messed up with a here-document (the "<< EOF" construct)


    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    Suggested Solutions

    In tuning file systems on the Solaris Operating System, changing some parameters of a file system usually destroys the data on it. For instance, changing the cache segment block size in the volume of a T3 requires that you delete the existing volu…
    This tech tip describes how to install the Solaris Operating System from a tape backup that was created using the Solaris flash archive utility. I have used this procedure on the Solaris 8 and 9 OS, and it shoudl also work well on the Solaris 10 rel…
    Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
    Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now