Problem with csh script

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Problem with csh script
# 1  
Old 02-20-2008
Problem with csh script

Hi All,

I have the following script.


cd /export/home/fastserv/bin
source /export/home/fastserv/bin/
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
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
# Now check do email
echo "%INF% Checking for error mail file" >> /export/home/fastserv/bin/log.txt
if (-e /export/home/fastserv/bin/ then
        cp /export/home/fastserv/bin/
        chmod 744
        rm -f
        source /export/home/fastserv/bin/
        echo "%INF% Sent error mail message - previous batch not picked up" >> /export/home/fastserv/bin/log.txt
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.

$sh -x
+ cd /export/home/fastserv/bin
+ source /export/home/fastserv/bin/ 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

SQL*Plus: Release - 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 - 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 - 64bit Production
With the Partitioning, OLAP and Data Mining options syntax error at line 38: `end of file' unexpected

Can anyone please advise what is the problem in my script?

# 2  
Old 02-21-2008
If I comment the following line, I am able to run the script without a syntax error

#source /export/home/fastserv/bin/

The file just contains some environment settings as follows

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

setenv ORACLE_HOME /dboracle/orabase/product/
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
# 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?

# 3  
Old 02-21-2008
I'm not familiar with csh but this is what I've found with Google:

Shell::Source - run programs and inherit environment changes -

Hope this helps.

# 4  
Old 02-21-2008
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', where 'sh' is usually a Bourne shell interpreter.
# 5  
Old 02-21-2008
Now, I am running the script with its absolute path as follows and the following error is being encountered.
$ /export/home/fastserv/bin/

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

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

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:
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?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk execution problem in csh

This has no error awk '($8==150) && ($4>=11.001 && $4 <= 12) && ($5>=91.001 && $5<=92){print}' OFS="\t" file following are unable to run in csh this is giving error awk: line 1: syntax error at or near not even working in terminal awk '($'$gr'=='$grn') && ($'$ll'>='$Y' && $'$ll' <= '$Ym')... (1 Reply)
Discussion started by: nex_asp
1 Replies

2. UNIX for Dummies Questions & Answers

Problem with simple csh scripting

I found my answer... (2 Replies)
Discussion started by: sjung9442
2 Replies

3. Shell Programming and Scripting

CSH missing - problem

Hi all, i need help with this code set login = (`cut -d ":" -f1 /etc/passwd.2001`) set group = (`cut -d ":" -f4 /etc/passwd.2001`) set name = (`cut -d ":" -f5 /etc/passwd.2001 | cut -d ":" -f1`) set i = 1 while ($#login > 0) set pom = `last $login | wc -l` if ($pom < 3) then... (1 Reply)
Discussion started by: Casualty
1 Replies

4. Shell Programming and Scripting

Execution problem with csh script

Hi All, I have a small issue with my csh script which I am using to FTP a file. What I know is...there are two commands to execute script.. 'sh <file>' & '\<file>'. When I execute my script with command 'sh <file>', it gives me syntax error while it runs successfully with command '\<file>'. I am... (3 Replies)
Discussion started by: ndd
3 Replies

5. Shell Programming and Scripting

Problem with endsw in csh

I am getting an error and can't figure out the problem breaksw: endsw not found. Problem has been solved now (0 Replies)
Discussion started by: kristinu
0 Replies

6. Shell Programming and Scripting

${name${i}} problem in CSH

Hello all, I tried the following commands in the cshell, but failed. ~Cshell %set i=2 ~Cshell %set fields${i}= ( ad dd dd ) ~Cshell %echo $fields${i} fields: Undefined variable. ~Cshell %echo ${fields${i}} Missing }. And i can see the $fields2 is already set as a local variable... (0 Replies)
Discussion started by: tpltp
0 Replies

7. Shell Programming and Scripting

csh failing to call an 2 embedded csh script

I have an extraordinary problem with a csh script.....(feel free to berate the use of this but I'm modifying an existing bunch of them) Anyway, I have a master csh script which in turn calls a second csh script. This second csh script is below. Within this second script are two compiled C++... (1 Reply)
Discussion started by: pollsizer
1 Replies

8. Shell Programming and Scripting

csh problem with while

Hello this my first post, so i hope you help me echo -n "Choose which square you want to hit of PL2 grid " set pl2_square = $< set i = 1 while ($i <= 6) if ($pl2_square == $pl2_ships) then $pl2_ships = x echo "" echo "" echo "PL1 has hitted a square of PL2" echo... (5 Replies)
Discussion started by: amaj1407
5 Replies

9. Shell Programming and Scripting

Problem accessing csh ?? (Newbie)

Hi All, Just recently started using a program in Unix for a client. I was sent a script to use but for some reason it's not working. The person who created the script first suggested I may need to edit the first line of the script so that it has the correct path for the csh file: #!/bin/csh -f... (3 Replies)
Discussion started by: gmalt
3 Replies

10. Shell Programming and Scripting

cron job problem with csh script

I've written a csh shell script to number each line of a file. Firstly, the program count the number of the file and create a file with number at the front. Then, combine the file together. when i call the program manually, it works.However, when i set it in the cronjob, the output always leaves... (3 Replies)
Discussion started by: fung_donald
3 Replies
Login or Register to Ask a Question