Visit The New, Modern Unix Linux Community


BCP with cat not working


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers BCP with cat not working
# 8  
Please post lines 338 until 343 of your script plus a few leading and trailing lines so we can verify the error message.
# 9  
Here is the lines of code

Code:
bcp_in() {
#echo  -e "\n\n\t\tbcp in $_currdate"

  echo -e 
  echo -e "BCP: $_currdate input file information into logfile table...\n"

  cat <<-endOfCat | bcp ${_DBName}..logfile in ${_currdate} -f$P/format/logfile.fmt -Q  -U$_UserId -P$_Password
  endOfCat

  if [ $? -ne 0 ]
  then
    echo -e "\n\n\t\tError in BCP. Verify the command"
   # delete_tables       
   # abort_message
  fi
}


bcp_out() {
#echo  -e "\n\n\t\tbcp out for file $_currdate"

echo -e "\n\n\t\tbcp out for file $_errfile"
}

#main

#Check for minumum number of arguments 
#
if [ $# -ne 4 ]
then
  print_version
  echo -e "\nUsage:" ${PROG}" THIS JOB IS TO BE RUN AS AUTOSYS JOB.PLEASE READ THE JOB DOCUMENT  \n"
  exit 1
fi
# Move the parameters into variables
_DBName=$1
_UserId=$2
_javadebug=`echo -e $JAVA_DEBUG`
export JAVA_DEBUG=0
_EncryptedPassword=$3
_Password=`$P_HOME/bin/jrun.ksh`
export JAVA_DEBUG=_javadebug
_indicator=$4
_ProcessId=$$


if [ $_indicator -eq 1 ]
then    
   _day1="$(date '+%a')"
   _day2="Tue"

   if [ $_day1 == $_day2 ]
   then
      echo "processing the file for 2 days before"
      _prev2date="log$(date -d "2 days ago" +"%y%j")"
      

      _currdate=$P/receiver/$_prev2date
      _logfile_name=$_prev2date
      _errfile=$PANEL_OUTPUTFILE_PATH/$_prev2date"_err"
     
_vercor_prev2date="vercor_$(date -d "2 days ago" +"%y%j")_001.txt"
      _ver_prev2date="ver_$(date -d "2 days ago" +"%y%j")_001.txt"
      
      _vercor_currdate=$P/receiver/$_vercor_prev2date
      _ver_currdate=$P/receiver/$_ver_prev2date

     # process_ver_file 
      process_input_file

      echo  "processing the file for previous_day"
      _prev1date="log$(date -d "yesterday" +"%y%j")"
      _currdate=$P/receiver/$_prev1date
      _logfile_name=$_prev1date
      _errfile=$PANEL_OUTPUTFILE_PATH/$_prev1date"_err"
      
      _vercor_prev1date="vercor_$(date -d "yesterday" +"%y%j")_001.txt"
      _ver_prev1date="ver_$(date -d "yesterday" +"%y%j")_001.txt"
            
      _vercor_currdate=$P/receiver/$_vercor_prev1date
      _ver_currdate=$P/receiver/$_ver_prev1date
      
      #process_ver_file
      process_input_file

      echo "processing the file for current_day"
     _currdate=$P/receiver/"log$(date '+%y%j')"
     _logfile_name="log$(date '+%y%j')"
     _errfile=$PANEL_OUTPUTFILE_PATH/"log$(date '+%y%j')_err"

     _vercor_currdate=$P/receiver/"vercor_$(date '+%y%j')_001.txt"
     _ver_currdate=$P/receiver/"ver_$(date '+%y%j')_001.txt"

#      process_ver_file
      process_input_file
   else
     echo processing the file for current_day
     _currdate=$P/receiver/"log$(date '+%y%j')"
     _errfile=$PANEL_OUTPUTFILE_PATH/"log$(date '+%y%j')_err"

     _vercor_currdate=$P/receiver/"vercor_$(date '+%y%j')_001.txt"
      _ver_currdate=$P/receiver/"ver_$(date '+%y%j')_001.txt"


     process_input_file
   fi

else
     echo processing the file for current_day
     _currdate=$P/receiver/"log$(date '+%y%j')"
     _errfile=$PANEL_OUTPUTFILE_PATH/"log$(date '+%y%j')_err"

     _vercor_currdate=$P/receiver/"vercor_$(date '+%y%j')_001.txt"
      _ver_currdate=$P/receiver/"ver_$(date '+%y%j')_001.txt"


     process_input_file
fi

# Display the success message
success_message

exit 0

# 10  
man bash:
Quote:
If the redirection operator is <<-, then all leading tab characters are stripped from input lines and the line containing delimiter. This allows here-documents within shell scripts to be indented in a natural fashion.
You're using two spaces so bash doesn't recognize the "endOfCat".
The question still is WHY are you supplying just an end-of-file to bcp with this here-document construct?
This User Gave Thanks to RudiC For This Post:
# 11  
HI,

I just took over from a script in our application where it is working fine. Don't have my own intention to use the "endOfCat". Not sure how it is working there

Thanks,
Arun
# 12  
Quote:
Originally Posted by arunkumar_mca
I just took over from a script in our application where it is working fine. Don't have my own intention to use the "endOfCat". Not sure how it is working there
There is no "error of cat" and "endOfCat" is no command - it is just a label saying that the "here-document", which began with "<<-endOfCat" ends there. The error is in fact a shell error because what you have written makes no sense.

Why don't you just use the the working (and, as far as i can see it, perfectly reasonable) line but instead try to use the here-document? What are you trying to achieve? This has been asked already several times and there is still no answer from you. How about explaining this first?

I hope this helps.

bakunin
This User Gave Thanks to bakunin For This Post:
 

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Test Your Knowledge in Computers #910
Difficulty: Easy
In C, you can declare a pointer as follows: data_type * pointer_variable_name;
True or False?

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Cat command not working to display Mac file in Ubuntu

Hi, Recently I got a .txt file from Mac user. when I try to open it in my Ubuntu machine using cat command it is not displaying any content of file however I can see the content using vi. Anyone know How to see its content using cat as I have to process it in my shell script. Thanks in... (4 Replies)
Discussion started by: diehard
4 Replies

2. Shell Programming and Scripting

bcp error

hi all, Getting error while working on sybase::bcp as below, DB-Library error: Attempt to convert data stopped by syntax error in source field. Code is like, my $bcp_files = new Sybase::BCP $usr, $pass, $server; ---------- Post updated at 02:05 AM ---------- Previous update... (0 Replies)
Discussion started by: Deei
0 Replies

3. Shell Programming and Scripting

bcp command help

Hi, When i execute a script in unix, the result i got is :: ./purgeErrors.ksh: bcp: not found What is the meaning of that output ? --- Aditya (9 Replies)
Discussion started by: chaditya
9 Replies

4. Shell Programming and Scripting

sybase::bcp

I am trying to bcp in using sybase::bcp perl module. I can find we can give user, pwd and server name in the parameters. How can I give database and table name? (1 Reply)
Discussion started by: Deei
1 Replies

5. Shell Programming and Scripting

BCP command or module

Hi All, I am trying to bcp in data file into database. now there is bcp command available in unix and another perl module Sybase::BCP is also available. Can anyone please let me know if there is any limitations of bcp command in unix. whichever is good to use? (1 Reply)
Discussion started by: Deei
1 Replies

6. OS X (Apple)

Cat command not working as expected

I've been trying to figure this out since last night, and I'm just stumped. The last time I did any shell scripting was 8 years ago on a Unix box, and it was never my strong suit. I'm on a Mac running Leopard now. Here's my dilemma - hopefully someone can point me in the right direction. I'm... (10 Replies)
Discussion started by: Daniel M. Clark
10 Replies

7. Shell Programming and Scripting

cat in the command line doesn't match cat in the script

Hello, So I sorted my file as I was supposed to: sort -n -r -k 2 -k 1 file1 | uniq > file2 and when I wrote > cat file2 in the command line, I got what I was expecting, but in the script itself ... sort -n -r -k 2 -k 1 averages | uniq > temp cat file2 It wrote a whole... (21 Replies)
Discussion started by: shira
21 Replies

8. UNIX for Advanced & Expert Users

cat and grep not working

I am trying to cat a file and then grep that file for a number. I can do it fine on other files but this particular file will not do anything. I tried running it on an older file from the same device but it is just not working. The file is nothing more than a flat file on a unix box. Here is just a... (3 Replies)
Discussion started by: jphess
3 Replies

9. UNIX for Dummies Questions & Answers

Difference between cat , cat > , cat >> and touch !!!

Hi Can anybody tell the difference between Difference between cat , cat > , cat >> and touch command in UNIX? Thanks (6 Replies)
Discussion started by: skyineyes
6 Replies

Featured Tech Videos