The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
script problem tdavenpo Shell Programming and Scripting 3 01-04-2006 04:07 PM
Problem starting a script from a 'main'-script Rakker UNIX for Dummies Questions & Answers 3 06-28-2005 08:12 AM
problem with a script Lestat Shell Programming and Scripting 4 06-13-2005 12:30 PM
script problem Bab00shka Shell Programming and Scripting 4 09-16-2002 10:21 AM
problem with ftp script...please help vancouver_joe UNIX for Advanced & Expert Users 2 11-22-2001 07:47 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 02-20-2008
rahulrathod rahulrathod is offline
Registered User
  
 

Join Date: Sep 2004
Location: Mumbai-India
Posts: 158
Problem with csh script

Hi All,

I have the following script.

Code:
#!/bin/csh
#
# createDATfile.sh
#


cd /export/home/fastserv/bin
source /export/home/fastserv/bin/dbenv.sh
echo `date` >> /export/home/fastserv/bin/log.txt
echo "%INF% Starting send of current FASTSERVICE batch" >> /export/home/fastserv/bin/log.txt
sqlplus fastsrv/fastsrv << EOF
set serveroutput on
begin
        create_fastsrv_file;
end;
.
/
EOF
if (-e /export/home/fastserv/bin/NORECORDS) then
        echo "%INF% No records created" >> /export/home/fastserv/bin/log.txt
        rm -f /export/home/fastserv/bin/NORECORDS
endif
#
# Now check do email
#
echo "%INF% Checking for error mail file" >> /export/home/fastserv/bin/log.txt
if (-e /export/home/fastserv/bin/mailFASTSRVerror.sh) then
        cp /export/home/fastserv/bin/mailFASTSRVerror.sh send.sh
        chmod 744 send.sh
        rm -f mailFASTSRVerror.sh
        source /export/home/fastserv/bin/send.sh
        rm send.sh
        echo "%INF% Sent error mail message - previous batch not picked up" >> /export/home/fastserv/bin/log.txt
endif
echo "%INF% Script completed" >> /export/home/fastserv/bin/log.txt
echo `date` >> /export/home/fastserv/bin/log.txt

When I run the script as follows, I get the output as below.

Code:

$sh -x createFASTSRVfile.sh
+ cd /export/home/fastserv/bin
+ source /export/home/fastserv/bin/dbenv.sh
createFASTSRVfile.sh: source: not found
+ date
+ echo Wed Feb 20 17:26:36 GMT 2008
+ echo %INF% Starting send of current FASTSERVICE batch
+ sqlplus fastsrv/fastsrv
set serveroutput on
begin
        create_fastsrv_file;
end;
.
/

SQL*Plus: Release 10.1.0.3.0 - Production on Wed Feb 20 17:26:36 2008

Copyright (c) 1982, 2004, Oracle.  All rights reserved.


Connected to:
Oracle Database 10g Enterprise Edition Release 10.1.0.3.0 - 64bit Production
With the Partitioning, OLAP and Data Mining options

SQL> SQL>   2    3    4  SQL>
PL/SQL procedure successfully completed.

SQL> Disconnected from Oracle Database 10g Enterprise Edition Release 10.1.0.3.0 - 64bit Production
With the Partitioning, OLAP and Data Mining options
createFASTSRVfile.sh: syntax error at line 38: `end of file' unexpected
Can anyone please advise what is the problem in my script?

Thanks,
Rahul.
  #2 (permalink)  
Old 02-21-2008
rahulrathod rahulrathod is offline
Registered User
  
 

Join Date: Sep 2004
Location: Mumbai-India
Posts: 158
If I comment the following line, I am able to run the script without a syntax error

Code:
#source /export/home/fastserv/bin/dbenv.sh
The file just contains some environment settings as follows

Code:
#! /bin/csh
#
set history=32
stty sane

setenv ORACLE_HOME /dboracle/orabase/product/10.1.0.3
setenv ORACLE_BASE /dboracle/orabase
setenv LD_LIBRARY_PATH $ORACLE_HOME/lib:/usr/dt/lib:/usr/lib:/usr/ccs/bin:/usr/ucb:/usr/openv/netbackup/bin
setenv ORACLE_OWNER oracle
setenv ORACLE_TERM vt220
setenv ORACLE_SID MYDB
setenv ORACLE_BIN ${ORACLE_HOME}/bin
# Set up common environment
setenv PATH ${ORACLE_BIN}:${ORACLE_HOME}:/bin:/usr/sbin:/usr/bin:/bin:/usr/openwin/bin:${PATH}

alias dbenv source ~oracle/.dbenv
alias dba "sqlplus '/ as sysdba'"
Any idea what is wrong in the source command?

thanks,
Rahul.
  #3 (permalink)  
Old 02-21-2008
Franklin52 Franklin52 is offline Forum Staff  
Moderator
  
 

Join Date: Feb 2007
Posts: 4,293
I'm not familiar with csh but this is what I've found with Google:

Shell::Source - run programs and inherit environment changes - search.cpan.org

Hope this helps.

Regards
  #4 (permalink)  
Old 02-21-2008
vgersh99's Avatar
vgersh99 vgersh99 is online now Forum Staff  
Moderator
  
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 5,119
there's nothing 'wrong' with the 'source' command.
What is wrong though is that you have a 'csh' script and you're calling it with 'sh -x createFASTSRVfile.sh', where 'sh' is usually a Bourne shell interpreter.
  #5 (permalink)  
Old 02-21-2008
rahulrathod rahulrathod is offline
Registered User
  
 

Join Date: Sep 2004
Location: Mumbai-India
Posts: 158
Now, I am running the script with its absolute path as follows and the following error is being encountered.
Code:
$ /export/home/fastserv/bin/createFASTSRVfile.sh

SQL*Plus: Release 10.1.0.3.0 - Production on Thu Feb 21 16:36:47 2008

Copyright (c) 1982, 2004, Oracle.  All rights reserved.

ERROR:
ORA-01034: ORACLE not available
ORA-27101: shared memory realm does not exist
SVR4 Error: 2: No such file or directory


Enter user-name: SP2-0306: Invalid option.
Usage: CONN[ECT] [logon] [AS {SYSDBA|SYSOPER}]
where <logon>  ::= <username>[/<password>][@<connect_identifier>] | /
Enter user-name: Enter password:
ERROR:
ORA-01005: null password given; logon denied


SP2-0157: unable to CONNECT to ORACLE after 3 attempts, exiting SQL*Plus
The username password in the script is correct and I am able to conect to the database using it.

Anything similar to sh -x, we have in csh to debug?
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 04:18 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0