This content has been marked as final. Show 12 replies
I'm not sure what you want here. As Dude explained, the "$" character means something very specific to the shell. Once you prepend it to text, it means to interpret it as a variable. There's no way around it. That's why they <b>have</b> the ability to escape it with the \ character or enclose it in single-quotes...
Many thanks for replies!
i know the $ is a special character in shell script.
bash see it as the begin of variable bla..bla..
But the requirement is:
i want to write a script, which take input as a SQL-Select string from SQLPlus,
execute it.. and the result output goto to a file...
Now when we want make a Select, wen say in SQLPlus for example:
SQL> select * from v$datafile;
SQL> select \* from v\$datafile; or SQL> 'select * from v$datafile'; or SQL> select * from 'v$datafile';
the idea with last command from history is good!!
First i can not unterstand the sha-bang/bash-bang. Why should it be on comment?
And it run correct when called direct in Shell (Terminal), but not when called in SQLPlus
run direct from shell:
run from SQLPlus:
[oracle@oel57 bin]$ ./testme a b $c a b $c [oracle@oel57 bin]$
it's great when you have a idea for me!
SQL> !testme a b $c SQL>
This is exactly what i want! Why not?
It is possible to run a Linux command or bash script from SQLPlus.
It begin with "!" and the script can have parameter too!
You can say:
SQL> !ls -l /u01/app
It is possible, also i do it!
My script should have following functions:
- take the SQL statement from SQLPlus as paraameter,
- execute the SQL
- spool the result to a temp file.
- format the select result: elimnate unwanted the column spacing
- present again in SQLPlus
It look like this:
do_select_format is the name of my script!
SQL>!do_select_format select * from v$logfile;
and i see somthing like this:
Note: i dont want to say: col format xxxx xxx ... before!
GROUP# STATUS TYPE MEMBER IS_ ====== ====== ====== ========================================== === 3 ONLINE +DATA/orcl/onlinelog/group_3.266.780357305 NO 3 ONLINE +DATA/orcl/onlinelog/group_3.267.780357305 YES 2 ONLINE +DATA/orcl/onlinelog/group_2.264.780357303 NO 2 ONLINE +DATA/orcl/onlinelog/group_2.265.780357303 YES 1 ONLINE +DATA/orcl/onlinelog/group_1.262.780357301 NO 1 ONLINE +DATA/orcl/onlinelog/group_1.263.780357303 YES 6 rows, 5 columns found!
Edited by: DBA(t home) on May 8, 2012 4:44 AM
Edited by: DBA(t home) on May 8, 2012 4:46 AM
Note that you would want to do:
./test.sh aa '$bb' cc
If you enclose all of the parameters in the single quotes then they will be read as one variable.
I think that you have to accept that that is the way that the shell is written, and so you have to use quotes (or backslash) to stop certain characters being interpreted; this includes '$' (denotes a variable), '#' (start of comment), and ' ' (space, eg. in filenames).
You can turn off filename expansion with noglob (so that '?' and '*' are taken literally and don't have wildcard meanings), but that doesn't work for '$'...
[paul@vmlxoel64 Desktop]$ ls -l
-rw-rw-r--. 1 paul paul 0 May 11 09:27 blah
-rw-rw-r--. 1 paul paul 0 May 11 09:28 z
[paul@vmlxoel64 Desktop]$ echo * ?
blah z z
[paul@vmlxoel64 Desktop]$ set -f; echo * ?; set +f