Sponsored Content
Top Forums Shell Programming and Scripting Execution problems to call the DB table through UNIX Post 303002367 by spidy on Wednesday 23rd of August 2017 07:13:51 AM
Old 08-23-2017
Execution problems to call the DB table through UNIX

Hi All,

I am beginner to the Unix scripting, i am writing a script to call the DB through Unix script. I have to read the files from the given path and in each file the first column i have to pick up and delete the row in the table based on that column.
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"

if [ "$FILECOUNT" -ge 1 ]
then
    for file in "$FILENAMEPAT"*;
    do
      RECCOUNT=`cat ${file}| wc -l`
      echo "$RECCOUNT"
      if [ "$RECCOUNT" -gt 1 ]
      then
	  #!/bin/sh
      user="GLOBALDATA"
      pass="duVuqi50"
	  Search_Term = $(cut -d'|' -f1 ${file}|sed 1d)
      sqlplus -S $user/$pass <<EOF
      DELETE FROM SEARCH_TERM WHERE SEARCH_TERM_TX=$Search_Term;
      exit;
      EOF
      else
      echo "file has no records to process"
      fi
	done
else
    echo "No files exists with pattern "$FILENAMEPAT" in the path to process"
    exit 1
fi
#End Of Script

I am getting below error and correct me if the script is wrong

Code:
: invalid optionte.sh: line 12: set: -
set: usage: set [--abefhkmnptuvxBCHP] [-o option-name] [arg ...]
'earch_Term_Delete.sh: line 38: syntax error near unexpected token `
'earch_Term_Delete.sh: line 38: `    for file in "$FILENAMEPAT"*;

Thanks in advance!!

Last edited by rbatte1; 08-23-2017 at 08:43 AM.. Reason: Correctted 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
MYSQL_FIX_PRIVILE(1)					       MySQL Database System					      MYSQL_FIX_PRIVILE(1)

NAME
mysql_fix_privilege_tables - upgrade MySQL system tables SYNOPSIS
mysql_fix_privilege_tables --password=root_password DESCRIPTION
Note In MySQL 5.1.7, mysql_fix_privilege_tables was superseded by mysql_upgrade, which should be used instead. See mysql_upgrade(1). Some releases of MySQL introduce changes to the structure of the system tables in the mysql database to add new privileges or support new features. When you update to a new version of MySQL, you should update your system tables as well to make sure that their structure is up to date. Otherwise, there might be capabilities that you cannot take advantage of. mysql_fix_privilege_tables is an older script that previously was used to uprade the system tables in the mysql database after a MySQL upgrade. Before running mysql_fix_privilege_tables, make a backup of your mysql database. On Unix or Unix-like systems, update the system tables by running the mysql_fix_privilege_tables script: shell> mysql_fix_privilege_tables You must run this script while the server is running. It attempts to connect to the server running on the local host as root. If your root account requires a password, indicate the password on the command line like this: shell> mysql_fix_privilege_tables --password=root_password The mysql_fix_privilege_tables script performs any actions necessary to convert your system tables to the current format. You might see some Duplicate column name warnings as it runs; you can ignore them. After running the script, stop the server and restart it so that any changes made to the system tables take effect. On Windows systems, MySQL distributions include a mysql_fix_privilege_tables.sql SQL script that you can run using the mysql client. For example, if your MySQL installation is located at C:Program FilesMySQLMySQL Server 5.1, the commands look like this: C:> cd "C:Program FilesMySQLMySQL Server 5.1" C:> binmysql -u root -p mysql mysql> SOURCE share/mysql_fix_privilege_tables.sql Note Prior to version 5.1.17, the mysql_fix_privilege_tables.sql script is found in the scripts directory. The mysql command will prompt you for the root password; enter it when prompted. If your installation is located in some other directory, adjust the path names appropriately. As with the Unix procedure, you might see some Duplicate column name warnings as mysql processes the statements in the mysql_fix_privilege_tables.sql script; you can ignore them. After running the script, stop the server and restart it. COPYRIGHT
Copyright 2007-2008 MySQL AB, 2008-2010 Sun Microsystems, Inc. This documentation is free software; you can redistribute it and/or modify it only under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. This documentation is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with the program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or see http://www.gnu.org/licenses/. SEE ALSO
For more information, please refer to the MySQL Reference Manual, which may already be installed locally and which is also available online at http://dev.mysql.com/doc/. AUTHOR
Sun Microsystems, Inc. (http://www.mysql.com/). MySQL 5.1 04/06/2010 MYSQL_FIX_PRIVILE(1)
All times are GMT -4. The time now is 02:31 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy