Adding timestamp after cat <<EOF >


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Adding timestamp after cat <<EOF >
# 1  
Old 06-15-2011
Adding timestamp after cat <<EOF >

Hi Team,
I am trying to add timestamp to SQLs by taking the timestamp in variable through shell script.I started like this.
Code:
cat << EOF > $MYDIR
CONNECT TO $MYDB USER $MYUSR USING $MYPWD;
T=`db2 -x "select CURRENT_TIMESTAMP from sysibm.sysdummy1 "`;

DECLARE RECCUR CURSOR FOR XXXXXXXXXXXXXXXXXXXXXX
LOAD FROM RECCUR OF CURSOR XXXXXXXXXXXxxx

when i try to execute the above connect to database is working but at the T line its giving error .
"
T=SQL1024N A database connection does not exist. SQLSTATE=08003
DB21034E The command was processed as an SQL statement because it was not a
valid Command Line Processor command. During SQL processing it returned:
SQL1024N A database connection does not exist. SQLSTATE=08003"

Can some body suggest how to add timestamp after cat <<EOF > to a variable using db2 commands or using linux comands?
Regards








valid Command Line Processor command. During SQL processing it returned:
SQL1024N A database connection does not exist. SQLSTATE=08003
# 2  
Old 06-15-2011
Seems the error is related to DB2.Can you check here and revert..?
# 3  
Old 06-15-2011
Yes ,That is related to db2 but does the sytnax prompting to give this error ?
did that timestamp syntax looks ok do i need to change some thing ? Even the before connect statement connected.Is this correct ?

CUR_TIME=`db2 -x "select CURRENT_TIMESTAMP from sysibm.sysdummy1 "`;

Inside a cat << EOF > will the above will work ?

Regards
# 4  
Old 06-15-2011
Quote:
Inside a cat << EOF > will the above will work ?
No. The "T=" line has become part of the SQL program ... and failed a SQL syntax check.
Also, there is no trailing "EOF" line in your script to terminate the Here Document.
The Shell "T=" line needs to be before or after the Here Document depending on whether you want to use the start time or the end time. You could of course use the unix "date" commmand to get the current date and time in any format you desire (but still outside of the Here Document).
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Adding a timestamp every N row in another column

Hi, i have a raw output file like this 167,63.50 167,63.50 168,63.68 166,63.68 168,63.68 I would like to add every each N rows (for example 60) and in a third column , a timestamp using the command date +"%H:%M"how can i do it with one single command ? Thank you !! (5 Replies)
Discussion started by: Board27
5 Replies

2. UNIX for Dummies Questions & Answers

Sendmail with cat adding extra spaces in email body

when I try to read a file and send email using cat and sendmail: The email received having additional spaces.(Between the letters of words in the text) My code: export MAILTO="sa@y.com" export SUBJECT="mydomain PREPROD MONITOR AT ${DATE}" export... (5 Replies)
Discussion started by: visitsany
5 Replies

3. Shell Programming and Scripting

Mailx - Adding timestamp in CSV file

Hi allI am mailing csv file to our lotusnote server using shell script. I am using command to get require date/time :date +"%d%b%y-%X%p"File name is :TESTFILE-29Jan14-09:00:00AM.csv.When I am receving this on lotusnote server coming as "00AM.csv" rest of the string is getting truncated. I feel due... (1 Reply)
Discussion started by: krsnadasa
1 Replies

4. Shell Programming and Scripting

What's wrong with my cat EOF?

cat << EOF > tmp.sh #!/bin/sh mknod /dev/`cat /proc/devices | grep xx | sed -r 's/(.*) (.*)/\2 c \1/'` 0 chmod 777 /dev/xx (1 Reply)
Discussion started by: yanglei_fage
1 Replies

5. UNIX for Dummies Questions & Answers

Move Multiple Files adding date timestamp before file type

There are files in a directory and I have to move multiple files adding datetimestamp before the file type. /Data/ abc.csv def.csv ghi.csv I have to move this files to archive directory adding datatimestamp before .csv /archive/ abc_YYYYMMDDHHMMSS.csv def_YYYYMMDDHHMMSS.csv... (7 Replies)
Discussion started by: eskay
7 Replies

6. Shell Programming and Scripting

Parsing a timestamp until EOF

hey guys, i'm having a bit of trouble with my script. based on the time you started a shift for work, it's supposed to read the input, and then parse a log file of alerts accordingly. my issue is parsing out from the time entered as your start time until the end of the file. the format looks like... (6 Replies)
Discussion started by: terrell
6 Replies

7. Shell Programming and Scripting

Adding timestamp to all inbound files

hi, can someone give me a sample shell scripts to make all inbound files will a have a Moveit timestamp.I think MoveIt is a server,thanks. (5 Replies)
Discussion started by: sonja
5 Replies

8. Shell Programming and Scripting

cat redirect EOF missing text

Hello attempting to redirect out to create a startup script in solaris. The steps are working but the $1 entry is being left out. syntax below and content of output file below. cat > S99build << EOF > #!/bin/bash > case $1 in > 'start') > /usr/os-buildsol.sh > > ;; > esac > exit 0 >... (3 Replies)
Discussion started by: juanb25
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

10. UNIX for Dummies Questions & Answers

regarding cat and EOF in UNIX

Hi, Can anyone explain me what this function is doing cat << EOF > HELPFILE /$1/ { print "SENT" } EOF Thanks in Advance Suggestions welcome (1 Reply)
Discussion started by: trichyselva
1 Replies
Login or Register to Ask a Question