Sponsored Content
Top Forums Shell Programming and Scripting Execution problems to call the DB table through UNIX Post 303002389 by spidy on Wednesday 23rd of August 2017 10:45:29 AM
Old 08-23-2017
Thanks RudiC!!
I have modified the script little bit, now its failing in the DB connection part.I am able to connect to the DB through UNIX when i run the only DB script part(in another script) but i am unable to execute that in the entire script,Please look into the code and correct me
Code:
#!/bin/sh
set -x
# Check to see if source file path is given
if [ -z "$1" ]
then
  echo "Usage: Source Path is required in position 1"
  exit 1
else
  SRCFILEPATH=$1
  echo "Source path: $SRCFILEPATH"
fi
# Check to see if the file name pattern is given
if [ -z "$2" ]
then
  echo "Usage: File Name Pattern is required in position 2"
  exit 1
else
  FILENAMEPAT=$2
  echo "File Name Pattern: $FILENAMEPAT"
fi
#Moving to src directory
cd $SRCFILEPATH
pwd
FILECOUNT=`ls *"$FILENAMEPAT"*|wc -l`
echo $FILECOUNT
   for file in "$FILENAMEPAT"*;
   do
   if [ "$FILECOUNT" -gt 1 ]
   then
   user="GLOBALDATA"
   pass="duVuqi50"
   ServiceName="xxxx"
   sqlplus -S $user/$pass@ServiceName <<_EOF_
      SELECT * FROM SEARCH_TERM ;
      exit;
      _EOF_
      else
      echo "file has no records to process"
      exit 1
      fi
   done
#End of Script

Error I am getting
Code:
etluser@avocado1:/var/local/ei/etl/Scripts>sh test_2.sh var/local/ei/etl/Scripts Search_Term
+ '[' -z var/local/ei/etl/Scripts ']'
+ SRCFILEPATH=var/local/ei/etl/Scripts
+ echo 'Source path: var/local/ei/etl/Scripts'
Source path: var/local/ei/etl/Scripts
+ '[' -z Search_Term ']'
+ FILENAMEPAT=Search_Term
+ echo 'File Name Pattern: Search_Term'
File Name Pattern: Search_Term
+ cd var/local/ei/etl/Scripts
test_2.sh: line 32: cd: var/local/ei/etl/Scripts: No such file or directory
+ pwd
/var/local/ei/etl/Scripts
++ wc -l
++ ls Search_Term_Delete.sh Search_Term_Manual.txt
+ FILECOUNT=2
+ echo 2
2
test_2.sh: line 52: warning: here-document at line 43 delimited by end-of-file (wanted `_EOF_')
test_2.sh: line 53: syntax error: unexpected end of file


Moderator's Comments:
Mod Comment Please use CODE tags for data as well, as required by forum rules!

Last edited by RudiC; 08-23-2017 at 12:00 PM.. Reason: Added CODE tags.
 

9 More Discussions You Might Find Interesting

1. IP Networking

any system call in unix to access ip routing table

hi is there any system call by which ip routing table can be accessed. (1 Reply)
Discussion started by: vinodkumar
1 Replies

2. Programming

Problem with execution of fork system call if i use \n

hi all, i tried the following source codes: fork1.c: main() { printf("demo of fork\n"); fork(); printf("hello"); } output: demo of fork hello hello fork2.c: main() (3 Replies)
Discussion started by: pnirmala
3 Replies

3. Shell Programming and Scripting

Execution Problems!!

i have been working on this for a about 12 hours today say's end of file un expected any idea's using the bourne shell and its driving me nuts worked fine in bash but prof says make it work in bourne and good luck worth 13% any help would be awesome #!/bin/sh trap "rm mnt2/source/tmp/* 2>... (1 Reply)
Discussion started by: mrhiab
1 Replies

4. Shell Programming and Scripting

Execution Problems

this my source file ************* fixed *************** Begin equipmentId : d9 processor : fox number : bhhhhhh Variable # 1: Id : 100 Type : 9 nType : s gType : 5f mType : 4 LField : England DataField : london Length ... (6 Replies)
Discussion started by: teefa
6 Replies

5. Shell Programming and Scripting

Problems in execution of sqlscript in unix

I am new to unix and trying to execute sql script from unix. I have function already in database and trying to execute it from Cygwin unix and getting stuck. Can someone guide me where I wrote the shell script wrong sqlplus -s scott/tiger declare a number:=3; b number:=4; c number; d... (2 Replies)
Discussion started by: pyerragudi
2 Replies

6. Shell Programming and Scripting

Execution problems with sed

Hi,I confused how to use sed to deal with big file. example: the big file have some different urls just with filename. how can i use sed to fetch url except file name and replace to other urls with filename? thanks!!! (11 Replies)
Discussion started by: hshzh359
11 Replies

7. UNIX for Dummies Questions & Answers

Execution Problems with UNIX.

Hi Team, I created one file like tst.pl, it contains #!/usr/bin/perl use Spreadsheet::ParseExcel; During execution it's showing error like use: command not found. Pleast let me suggest how to use this perl menthods in Unix. Thanks in Advance, Reards, Harris (5 Replies)
Discussion started by: harris
5 Replies

8. Solaris

System call to get the routing table

I want to implement a feature in my project where I want to attach the virtual IP on the interface present at the top in Routing table. I know the command to print the routing table, its "netstat -r". But I need a system call, so that I don't have to go for parsing . Can someone please provide any... (1 Reply)
Discussion started by: amitanshu.verma
1 Replies

9. UNIX for Beginners Questions & Answers

Execution problems

How to find a word in a directory which contains many files? i just want to count how many such words are present in all the files? This is the code which i tried for a single file echo "Enter the file name:" read file echo "Enter the word to search:" read word if then echo "The count... (4 Replies)
Discussion started by: Meeran Rizvi
4 Replies
exit(1)                                                            User Commands                                                           exit(1)

NAME
exit, return, goto - shell built-in functions to enable the execution of the shell to advance beyond its sequence of steps SYNOPSIS
sh exit [n] return [n] csh exit [ ( expr )] goto label ksh *exit [n] *return [n] DESCRIPTION
sh exit will cause the calling shell or shell script to exit with the exit status specified by n. If n is omitted the exit status is that of the last command executed (an EOF will also cause the shell to exit.) return causes a function to exit with the return value specified by n. If n is omitted, the return status is that of the last command exe- cuted. csh exit will cause the calling shell or shell script to exit, either with the value of the status variable or with the value specified by the expression expr. The goto built-in uses a specified label as a search string amongst commands. The shell rewinds its input as much as possible and searches for a line of the form label: possibly preceded by space or tab characters. Execution continues after the indicated line. It is an error to jump to a label that occurs between a while or for built-in command and its corresponding end. ksh exit will cause the calling shell or shell script to exit with the exit status specified by n. The value will be the least significant 8 bits of the specified status. If n is omitted then the exit status is that of the last command executed. When exit occurs when executing a trap, the last command refers to the command that executed before the trap was invoked. An end-of-file will also cause the shell to exit except for a shell which has the ignoreeof option (See set below) turned on. return causes a shell function or '.' script to return to the invoking script with the return status specified by n. The value will be the least significant 8 bits of the specified status. If n is omitted then the return status is that of the last command executed. If return is invoked while not in a function or a '.' script, then it is the same as an exit. On this man page, ksh(1) commands that are preceded by one or two * (asterisks) are treated specially in the following ways: 1. Variable assignment lists preceding the command remain in effect when the command completes. 2. I/O redirections are processed after variable assignments. 3. Errors cause a script that contains them to abort. 4. Words, following a command preceded by ** that are in the format of a variable assignment, are expanded with the same rules as a vari- able assignment. This means that tilde substitution is performed after the = sign and word splitting and file name generation are not performed. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | |Availability |SUNWcsu | +-----------------------------+-----------------------------+ SEE ALSO
break(1), csh(1), ksh(1), sh(1), attributes(5) SunOS 5.10 15 Apr 1994 exit(1)
All times are GMT -4. The time now is 05:48 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy