How to access variable from one file to another in shell script?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to access variable from one file to another in shell script?
# 8  
Old 10-05-2010
Still looks like there are spaces in front of your EOF line it must be in column 1.

Check return status ($?) following your sql command, it should tell you if the connect worked or not.

On your parameter reading, I like to use a function like this:
Code:
function param_val {
    sed -e "/^${1}=/!d" -e "s/${1}=//" $2 2> /dev/null
}

Then fetching the value reads a lot better
Code:
user=$( param_val USER $ConfigFile )
pass=$( param_val PASSWORD $ConfigFile )

# 9  
Old 10-05-2010
Yes, space is there, but now I am getting below message.
Code:
Usage: SQLPLUS [ [<option>] [<logon>] [<start>] ]
where <option> ::= -H | -V | [ [-L] [-M <o>] [-R <n>] [-S] ]
      <logon>  ::= <username>[/<password>][@<connect_string>] | / | /NOLOG
      <start>  ::= @<URI>|<filename>[.<ext>] [<parameter> ...]
        "-H" displays the SQL*Plus version banner and usage syntax
        "-V" displays the SQL*Plus version banner
        "-L" attempts log on just once
        "-M <o>" uses HTML markup options <o>
        "-R <n>" uses restricted mode <n>
        "-S" uses silent mode

Please help me out in this.
# 10  
Old 10-05-2010
Your calling sqlplus with a lower case s parameter but usage shows upper case (for silent mode).
# 11  
Old 10-05-2010
Still same message is coming.
If I had given the same on command prompt as,
Code:
sqlplus -S ora/ora

its showing below error message,
Code:
exec(): 0509-036 Cannot load program oracleALF because of the following errors:
        0509-150   Dependent module libjox9.a(shr.o) could not be loaded.
        0509-022 Cannot load module libjox9.a(shr.o).
        0509-026 System error: A file or directory in the path name does not exist.
ERROR:
ORA-12547: TNS:lost contact

My oracle server and shell script server is same but different login details are used.

Last edited by Poonamol; 10-05-2010 at 02:03 AM.. Reason: updating server info
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell script to pass the config file lines as variable on the respective called function on a script

I want to make a config file which contain all the paths. i want to read the config file line by line and pass as an argument on my below function. Replace all the path with reading config path line by line and pass in respective functions. how can i achieve that? Kindly guide. ... (6 Replies)
Discussion started by: sadique.manzar
6 Replies

2. Shell Programming and Scripting

Using variable from shell script in perl file

Hey, So I have a shell script that outputs some variables, call them $a and $b. I know in shell scripting if I wanted to use the variables in another shell script I'd do sh code.sh "$a" "$b" How can I do something similar with perl? (2 Replies)
Discussion started by: viored
2 Replies

3. Shell Programming and Scripting

Problem getting the content of a file in a shell script variable

Hi, I have a text file that has a long multi-line db2 CTE query. Now I want to store all the contents of this file (i.e. the entire query) in a shell script variable. I am trying to achieve it by this: query = `cat /Folder/SomeFile.txt` But when I echo the contents of this file by saying echo... (4 Replies)
Discussion started by: DushyantG
4 Replies

4. Shell Programming and Scripting

Getting category when given the variable from external file to shell script

Hi, I have a script that interacts with a config file in the format: file1.txt file2.txt file3.txt file4.txt file5.txt file6.txt I would like to return the Category, when given the file name. (11 Replies)
Discussion started by: MoreCowbell
11 Replies

5. Shell Programming and Scripting

(solved) Shell scripting to access SQLPLUS using variable

I have shell script which will try to login to SQL Plus and retrieve some data, based on the outcome i will proceed further Below is the content of the file pebblz02% cat test1.ksh #! /bin/ksh dummyvar=`sqlplus -S csm_admin/csm_admin@SIDNAME <<EOF echo hi; exit; EOF` Error message on... (0 Replies)
Discussion started by: kiranlalka
0 Replies

6. Shell Programming and Scripting

how to access variables in a config file inside a shell script

I'm writing a shell script. I want to put the variables in a separate config files and use those inside my script. e.g. the config file (temp.conf)will have the values like mapping=123 file_name=xyz.txt I want to access these variables in temp.conf(i.e. mapping and file_name) from inside the... (7 Replies)
Discussion started by: badrimohanty
7 Replies

7. Shell Programming and Scripting

Shell script to read file into variable

the script i am trying to write will allow my server to give itself an ip address. So far i am up to the following but i'm stuck. tracert -m 1 > traceroute.txt 1 routername (ipaddr) 2.094 ms 1.789 ms 1.243 ms i want to get ipaddr as a variable and use it to write the ifcfg-eth... (7 Replies)
Discussion started by: aspect_p
7 Replies

8. UNIX for Dummies Questions & Answers

accessing shell script variable in file

Hi, I have a shell script in which there is a file conn_$temp where $temp has the pid of the shell script. in this shell script i have an embedded awk script that must read the file while ((getline < "conn_$temp") > 0) However due to the "$temp" in the file name, the awk script is... (6 Replies)
Discussion started by: HIMANI
6 Replies

9. Shell Programming and Scripting

Read variable from file in a C shell script

Hi, I have a 1-line file which looks like " First second third 4 five". I need to extract the number (here 4) in that line and put it in a variable. I will use the variable later to make few tests in my C shell script. Can somebody help me? (2 Replies)
Discussion started by: haouesse
2 Replies

10. Shell Programming and Scripting

shell variable access

Hi I want to do the following: 1. Create a number of Gloabla varibale "ROUTE_IP_xx" based on a counter. As xx sould be from 1-10. ie ROUTE_IP_1 ROUTE_IP_2 . . ROUTE_IP_10 2. I want to initalize all of these variable to 0.0.0.0 ie ROUTE_IP_1='0.0.0.0' 3. I... (2 Replies)
Discussion started by: sabina
2 Replies
Login or Register to Ask a Question