Current position:  Home > Default > Shell script: How can i get the parameters of a command line?

Shell script: How can i get the parameters of a command line?

Time:November 30
Advertisement
Im a newbie. Help please!
For example my mini script test.sh
#!/bin/bash
echo all parameters: $*and now i run some test:
$ ./test.sh aa bb cc
all parameters: aa bb ccok!
$ ./test.sh aa bb $cc
all parameters: aa bbwhere is here $cc ?
$ ./test.sh aa $bb cc
all parameters: aa ccwhere is $bb ?
My question: How can i become 'aa $bb cc'? But without using of \  or ' or "  like this:
./test.sh aa \$bb cc
or
./test.sh 'aa $bb cc'Many thanks!
Advertisement
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
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:
SQL>!do_select_format select * from v$logfile;do_select_format is the name of my script!
and i see somthing like this:
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!Note: i dont want to say: col format xxxx xxx ... before!
Edited by: DBA(t home) on May 8, 2012 4:44 AM
Edited by: DBA(t home) on May 8, 2012 4:46 AM

Shell script calling SQL Program and passing parameters

-0001-11-30

Hi guys, Greetings from Toronto. Is it possible to pass a string or strings as parameters to a sql program from a shell script ? Shell Script # Accept system input parameters p_user_id=$1 p_job_id=$2 sqlplus.exe -s $p_user_id @$RD_PATH/rd_test.sql $p

Assigning parameters dynamically for command line processing

-0001-11-30

hi, how do i put the parameter dynamically for post processing in the file adapter? for processing UNIX scripting in the commandline in the receiver file adapter i need to use paramaters, like file name and directory dynamically. how can this be achi

OpenSSO Enteprise Configuration Parameters For the Command-Line Configurato

-0001-11-30

Hi, As said in the title, i want to configure OpenSSO Enteprise via command lines, but after doing the command: "java -jar configurator.jar -f ../../configuration_file" I have the following error: java.net.ConnectException: Connection refused at

Need a sample file for IDQ parameter file and a Shell script to execute it from command line

-0001-11-30

Hello,The parameter file itself is generated from cmd line using infacmd command and it automatically creates the parameters inside it based on the parameters created inside the mapping and the workflow. So, even if one provides you a paramtere file

What to use in shell script for CR when \n doesn't work.

-0001-11-30

Hi I'm new to LINUX and I'm writing a shell script. I noticed when I'm at the command line I can type: echo "one\ntwo" and it will produce: one two when I put that SAME line in a shell script I get: onentwo Why? What can I use as CR character in

Can't run shell script to save my life

-0001-11-30

Hello, I have a shell script which I need Java to start. When I pass the parameters in Java I get an exit value of 2. I never set an exit/error value of 2 in my code. What is even more strange, is that when I run the exact same strings I use in the p

Calling a report from a shell script

2015-10-11

We are modifying all concurrent programs to encrypt the oracle password by using the "ENCRYPT" option in the concurrent program definition for all unix based programs. The db user/password is derived from the FCP_LOGIN within the shell script. I

Shell Script not getting invoked in File adapter

2015-10-11

Hi all, Requirement: PI need to pick the file from source directory and send it to target directory using SFTP. I'm using SCP command for this purpose. When I run the shell script (with simple SCP command) from command prompt, script is working fine.

Procedure call and shell script

-0001-11-30

When i try to pass a shell variable to a procedure call in a shell script it does not work. But a SQL command ( insert ) has no problem taking the shell variable. Has this something to do with context switch. How to get around this prbokem. `sqlplus

Creating user account and setting password in Solaris9 through shell script

-0001-11-30

I need to create and set password of user through shell scripts. User can be added successfully through "useradd" command but password cant be set through "passwd" command in script. Is there any other alternative for the same.Hi, Did

Problems to run shell scripts in terminal

-0001-11-30

Hey mates, I'm not very experienced in writing shell scripts. However, I received a few shell scripts I wanted to execute. I used following command: chmod u+x model.sh I did not received any error message so that I think that this command works. Afte

SQL in Connection with shell scripts

-0001-11-30

Hello everyone, I have a conceptual question: If people like to implement their SQL-Scripts attached on a shell script(Ruby, Perl, or even OS-Shell), what are actually the benefits doing this? Can someone please give me a szenario, which is very effe

How to set plug-in Java Runtime parameters on JRE setup command line

2015-10-11

Hi all: I need to install JRE and set the Java Runtime Parameters -Xmx by command line .. I mean I don't want enter Control panel and set this parameter manually in Java Runtime Parameters textBox.. thanx. Best regards w.shihaDocumentation for contro

How to execute SAPGUI script from the command line?

-0001-11-30

I have created a script and would like to execute it from the command line. There must be some flag that goes with SAPGUI.EXE. Any help appreciated. Thanks, JeffHi Jeff, the best way to do this is to run the script using the Windows Script Host, for

FreeFlow Accxes Client Tools Command Line Parameters

-0001-11-30

We have a wide format scanner that is connect to our network via a HFT controller. I have installed the FreeFlow Accxes Client Tool on one of our engineering servers as a service. My issue is how to start automatic image retreval. Is there a method t

How to get return code or parameters from PL/SQL in my shell script ?

2015-10-11

My shell script must check the result of PL/SQL's running, and decide what to do in the next step.I think you put the problem the wrong way. You should try to do as much as possible through your SQL scripts, and, if you need to make OS calls, you may

Passing Multiple Parameters to SQL Script from a Shell Script

-0001-11-30

Hi Friends, I have SQL script which accepts 6 parameters. I am calling this from a shell script as shown below: sqlplus -s  ${ORACLE_ID} @${SQLPATH}KORONT_041.sql ${USER_ID} ${PDC} ${item_number} ${KORDC} ${PDCSET} ${last_Updated_in_hours} Out of the

Passing parameters from shell script to OWB process flow

-0001-11-30

Hi all, I am running OWB process flow (using the template script provided by oracle) and i want to pass two date parameters as shown below: sqlplus -s $SQL_USER/[email protected]$ORACLE_SID @$HOME_DIR/src/vmc_oem_exec_script.sql OWB_OWNER VMC_POST_DW_PF_LOC_

Parameters for Shell Script running through DBMS_SCHEDULER as Executable

-0001-11-30

Hi, I'm using Oracle 10.2.0.1 on Solaris. I have a shell script to run through DBMS_SCHEDULER. DBMS_SCHEDULER.CREATE_PROGRAM ( program_name => 'PROGRAM_NAME', program_type => 'EXECUTABLE', program_action => '/home/oracle/test.sh', enabled => T