need help with calling a config file in script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting need help with calling a config file in script
# 1  
Old 05-27-2010
need help with calling a config file in script

Hi,

I am writting a script and i am using SYBASE database. i have a config file with my logging credentials. when i am calling the file via isql command its throwing me an error. see the below code.

Code:
 
while read line
do

SERVER=`echo $linea |awk -F"|" ' {print $1} ' `
  CUSTOMER=`echo $linea |awk -F"|" ' {print $2} ' `
  server_id=`echo $linea |awk -F"|" ' {print $3} ' `
  User=`echo $linea |awk -F"|" ' {print $4} ' `
  Password=`echo $linea |awk -F"|" ' {print $5} ' `
 
isql -U<User> -P<Password> -S${SERVER} -D${CUSTOMER}  -b0 -w3000 -s"|" << END_FILE> ABC_${DATE}_${CUSTOMER}

this is what i have declared above isql this is calling a config file which have all the details. in the 2nd line i am calling the isql command.

I am also pasting my config file.
Code:
server|customer|5|daz|daz

can any1 tell me why it aint working? or what i am doing wrong. i am getting the below error.

Code:
User: cannot open

# 2  
Old 05-27-2010
try this:

Code:
while read line
do

SERVER=`echo $line |awk -F"|" '{print $1}' `
  CUSTOMER=`echo $line |awk -F"|" '{print $2}' `
  server_id=`echo $line |awk -F"|" ' {print $3} ' `
  User=`echo $line |awk -F"|" '{print $4}' `
  Password=`echo $line |awk -F"|" '{print $5}' `
 
isql -U<User> -P<Password> -S${SERVER} -D${CUSTOMER}  -b0 -w3000 -s"|" << END_FILE> ABC_${DATE}_${CUSTOMER
done < configfile


cheers,
Devaraj Takhellambam
# 3  
Old 05-27-2010
hehe Smilie

i am already doing that (i am sorry for misleading, kinda missed that step while pasting the code, because i am doing other operations after isql command).

any other ideas Smilie?
# 4  
Old 05-27-2010
your previous code had
SERVER=`echo $linea |awk -F"|" ' {print $1} ' `

instead of

SERVER=`echo $line |awk -F"|" '{print $1}' `
# 5  
Old 05-27-2010
printing mistake.
i am sorry for that. its a typo error.

---------- Post updated at 04:46 AM ---------- Previous update was at 04:46 AM ----------

any other clues. i am sure by now that you dont like me... :P

i m also trying on my end but cudnt find an answer for it
# 6  
Old 05-27-2010
Could you edit your first post to correct any typos you might have made? Or, if needed be, post the code without typos as an reply? That way we wouldn't be hunting down typos instead of errors.

Also, in your isql command line, are <User> and <Password> intentional placeholders, typos, or did you try to reference these variables in your script in this way? If it's the later, there's your error.

---------- Post updated at 11:56 ---------- Previous update was at 11:54 ----------

Side note: in newer versions of Bourne compatible shells (ksh/bash/zsh/...) it's recommended to use $( command ) instead of `command`, as it's more readable, and allows for nesting.

---------- Post updated at 11:59 ---------- Previous update was at 11:56 ----------

And you can improve the speed by avoiding unnecessary calls to awk:
Code:
while IFS='|' read SERVER CUSTOMER server_id User Password
do

    isql -U${User} -P${Password} -S${SERVER} -D${CUSTOMER}  -b0 -w3000 -s"|" << END_FILE> ABC_\${DATE}_${CUSTOMER}

done < configfile

This User Gave Thanks to pludi For This Post:
# 7  
Old 05-27-2010
thanks a lot for post. my errors is <User>.

and i m very sorry for making you guys hunt unnecessarily. but i swear i didnt do it on purpose i was also thinking where could i go wrong. isql was running properly 3hrs back and now its not running.
i will keep in mind to remove the typos if there are any from next time.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Pass config file to bash script

I just want to make sure I am understanding how to pass a config file to a bash script . In the below I pass to arguments to a script, then define them in the script as id and config. I then source config using ., if I understand correctly the variables in the config file can now be used by the... (11 Replies)
Discussion started by: cmccabe
11 Replies

2. 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

3. Shell Programming and Scripting

Calling a text file while executing a script

hi, I am trying to call a text file in a shell script. The text file has the variable defind like.. export vari_namee=/path/give/here ------------------------------------------------- I am able to execute the shell script through putty. But when I try to execute with informatica... (1 Reply)
Discussion started by: sunil0106
1 Replies

4. Shell Programming and Scripting

Config file edition by script

Hello. I am looking for a simple way to modify config files after a first install. I have a file containing the good key=value good_config.txt SSHAuthorizedKeys="authorized_keys" SSHD_PORT=54321 ENABLE_PASSDB_AUTHENTICATION="0" ENABLE_SSH_AUTHENTICATION="1" ENABLE_SU_AUTHENTICATION="0"... (3 Replies)
Discussion started by: jcdole
3 Replies

5. Shell Programming and Scripting

bash script config file

hi all config.sh : dhcp="0" setip="1" telnet="1" ping="1" main.sh function dhcp { } function setip { } (1 Reply)
Discussion started by: sadosan83
1 Replies

6. Shell Programming and Scripting

Shell script that will compare two config files and produce 2 outputs 1)actual config file 2)report

Hi I am new to shell scripting. There is a requirement to write a shell script to meet follwing needs.Prompt reply shall be highly appreciated. script that will compare two config files and produce 2 outputs - actual config file and a report indicating changes made. OS :Susi linux ver 10.3. ... (4 Replies)
Discussion started by: muraliinfy04
4 Replies

7. Shell Programming and Scripting

Calling Config file in the Script.. Please help

Hi Guys, I need some help related to my script... I will explain you briefly about my script and requirement I written one script which will monitor all my services in the server and send a mail to me.... There are about 10 Services(Processes) running on my services, and I have written 10... (1 Reply)
Discussion started by: Anji
1 Replies

8. Shell Programming and Scripting

parsing config file to create new config files

Hi, I want to use a config file as the base file and parse over the values of country and city parameters in the config file and generate separate config files as explained below. I will be using the config file as mentioned below: (config.txt) country:a,b city:1,2 type:b1... (1 Reply)
Discussion started by: clazzic
1 Replies

9. UNIX for Advanced & Expert Users

Calling sql file from shell script

Hi I have a shell script that call a sql file. The sql file will create a spool file. My requirement is, when ever i get an OS error like file not found. I have to log it in a log file. Could some who worked in a like scenario help me by giving the code sample. Many Thanks.. (1 Reply)
Discussion started by: chintapalli001
1 Replies

10. Shell Programming and Scripting

Edit a config file using shell script

I need to edit a config file using shell script. i.e., Search with the 'key' string and edit the 'value'. For eg: below is what I have in the config file "configfile.cfg". Key1=OldValue1 Key2=OldValue2 I want to search for "Key1" and change "OldValue1" to "NewValue1" Thanks for your... (7 Replies)
Discussion started by: rajeshomallur
7 Replies
Login or Register to Ask a Question