How do I reference the variable partname's value in the here doc?
I have quoted the relevant part of your script. You seem to think that a single-quoted string is somehow "stronger quoted" than a double-quoted one and that differently quoted strings can be nested. This is a - common - misconception.
Code:
wrong concept:
'........"............................"........'
<------------- single-quoted ---------------->
<- single+double-quoted---->"
'<-----> single-quoted only areas <------>
In fact it is like this: the shell maintains a flag "inside string y/n", which is flipped when a (fitting) quote is encountered. The first time the shell "sees" a quote char (single or double) it flips the flag to "y" and then waits until it gets the next fitting quote-char in the input. When getting this it flips the flag back. Everything read in the meantime is considered to be inside this string.
Code:
correct concept:
start reading, flag="outside string" right quote, flip flag to
| | "outside string" again
| flag="inside (single-quoted) string" |
| | |
| | |wrong quotes, flag unchanged| v
v v v v
....'........"............................"........'....>
<------------- single-quoted ---------------->
For your problem this means to do it like this:
Code:
partname=>"\'${partname}\'"
Notice the usage of escape-characters: they will preserve the single quotes for one pass of shell interpretation so that the resulting string will be a singly-quoted string.
Btw.: this
Code:
partname=$(
set pagesize 0 feedback off verify off heading off echo off;
sqlplus -s $username/$password@database<<pname
select A.PARTITION_NAME from DBA_TAB_STATISTICS A where table_name='TABLE_NAME_1' AND STALE_STATS='YES';
pname
)
may work but probably not in the way you intend it to do so. Consider changing the line order:
Code:
partname=$(
sqlplus -s $username/$password@database<<pname
set pagesize 0 feedback off verify off heading off echo off;
select A.PARTITION_NAME from DBA_TAB_STATISTICS A where table_name='TABLE_NAME_1' AND STALE_STATS='YES';
pname
)
I hope this helps.
bakunin
Last edited by bakunin; 02-26-2015 at 05:07 AM..
These 2 Users Gave Thanks to bakunin For This Post:
Hello,
has anyone written something that will monitor/gather weblogic heap info ? I need to gather size, high/low stats to a file that I can upload to a speadsheet
thanks for your help! (2 Replies)
Hi ,
i have created an .sh file that has the following code:
#!/bin/ksh
sqlplus -s p1istuat/p1istuat@CWS_IST6 @Procedure_Execute.sql &
sqlplus -s p1istuat/p1istuat@CWS_IST6 << EOF
exit
EOF
The mentioned Procedure_Execute.sql file inside has the following code:
exec TEST;
... (5 Replies)
I have a range of log files from rsync on an Ubuntu 10.04 server. At the bottom of these files, I have "--stats" -- a rsync switch -- which produces interesting information/statistics.
Steps the script will take:
take the the lines that contain the words "sent, total size, bytes"
put... (3 Replies)
Hi Gurus,
Want to execute a shell script from a oracle procedure and get the status of the same, any assistance in this regard will be appreciated.
proc_data.sh is script name which I want to execute from oracle procedure
It should work something like below
procedure test
begin... (1 Reply)
Hi,
I need to query Oracle database for 100 users. I have these 100 users in a file. I need a shell script which would read this User file (one user at a time) & query database.
For instance:
USER CITY
--------- ----------
A CITY_A
B CITY_B
C ... (2 Replies)
Hi can anyone help me with a script to load output of the .ksh file into an Oracle database. I have attached sample output of the information that i need to load to the database (2 Replies)
Hello,
I need to execute below command in shell script
srvctl relocate service -d $database -s $service -i $avail -t $pref -f and also need to get the errors ,if any,in another file.
What's the right way to execute such commands in shell script?
Best regards,
Vishal (1 Reply)
I want to create a shell script to gather user account information and displays the result to administrator.
I have created a script but its showing all the information when i search for username like:
amit@mx:~$ ./uinfo.sh amit
Username : amit
User Info ... (2 Replies)
Here is the shell script which need to trigger a stored procedure and when the record count is 0 then it should capture in the log that 0 duplicate records are found and if it's more than 0 then log with no of records. Also if there is any sqlerror then it should write the same in the log file and... (17 Replies)