If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Unix Shell Scripts > How to put a limit on the file size in k-shell

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-08-10, 11:11
orpurajesh orpurajesh is offline
Registered User
 
Join Date: Jul 2010
Posts: 5
How to put a limit on the file size in k-shell

Hi All,

I want to store 32KB of file in Oracle DB into CLOB field. I am not able to insert more than 32KB of file into CLOB. So i want to put a limit on the file size. I am using k shell.

My file size will dynamically increase its size, i want to check the file size if it is more than 32KB then put a limit and insert the same in CLOB field of DB.

I am using k-shell.

Please find below my code which is in place and let me know where i am doing wrong:

I am getting
ERROR:
ORA-01756: quoted string not properly terminated


myLogCount=$(cat $LogFile | wc -c)
echo "myLogCount in Actual Program::::: $myLogCount"
if [ $myLogCount -gt 32767 ]
then
awk '{n=n+length+1}
n <= 32500
n > 32500 {n-=length;print substr($0,1,(32500-n));exit}
' $LogFile > $myTmpLog

echo "Log file too large to view, Please visit server to view complete log" >> $myTmpLog
myTmpLogCount=$(cat $myTmpLog | wc -c)
br_Update_Proxy_Job_Run_Status "$Comment" \
"$RunStatusId" \
"$WarningCount" \
"" \
"" \
"" \
"" \
"" \
"$RptTotalRejectedDF" \
"$myTmpLog" \
"$ProxyJobStatus"
else
br_Update_Proxy_Job_Run_Status "$Comment" \
"$RunStatusId" \
"$WarningCount" \
"" \
"" \
"" \
"" \
"" \
"$RptTotalRejectedDF" \
"$LogFile" \
"$ProxyJobStatus"
fi









Please help appreciate if any sample script

Thanks,
Raj
Reply With Quote
  #2 (permalink)  
Old 07-08-10, 12:29
kitaman kitaman is offline
Papabi's friend
 
Join Date: Sep 2009
Location: Ontario
Posts: 629
You could simplify the size calculation by using the find command.
eg.

yes=`find ./ -name clob.file -size -63` # ( ie 63 x 512 char blocks or -32768c)
if $yes is equal to clob.file, the file is less than 32kb

If you want to save the first 32k of the file

dd if=clob.file of=clob.32k -bs=32k -count=1
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On