473,388 Members | 1,526 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

Shell Script - Problem found after read the KEY and VALUES from the property file

107 100+
Hi All,

I'm facing problem in shell script that read the value from properties file. I'm done with reading the property file by the below code

Property file looks like

Expand|Select|Wrap|Line Numbers
  1. NODE_NAME=xxxx
  2. WMQ_CONN_NAME=yyyy
  3. WMQ_CONN_TYPE=zzzz
  4.  
Shell Script Code:

Expand|Select|Wrap|Line Numbers
  1. get_prop(){ 
  2.     propfile=$1
  3.     key=$2
  4.     grep  "^${2}=" ${1}| sed "s%${2}=\(.*\)%\1%"
  5. }
  6.  
  7. NODE_NAME=`get_prop AppServerConfig.properties NODE_NAME`
  8. WMQ_CONN_NAME=`get_prop AppServerConfig.properties WMQ_CONN_NAME`
  9. WMQ_CONN_TYPE=`get_prop AppServerConfig.properties WMQ_CONN_TYPE`
  10.  
Continuation of the above code having the problem

Expand|Select|Wrap|Line Numbers
  1.  
  2. echo $NODE_NAME $WMQ_CONN_NAME $WMQ_CONN_TYPE
  3.  
  4.  
when i tried to print this

Expected Result:

Expand|Select|Wrap|Line Numbers
  1. xxxx yyyy zzzz
  2.  
But the Output comes like below

Expand|Select|Wrap|Line Numbers
  1. zzzz
  2.  
i tried below way to avoid this, but still having the same problem
Expand|Select|Wrap|Line Numbers
  1.  
  2. echo "${NODE_NAME}${WMQ_CONN_NAME}${WMQ_CONN_TYPE}"
  3.  
  4.  
Please help me to solve this issue

Thanks
Raju
Oct 30 '13 #1
5 3315
rski
700 Expert 512MB
Your code works fine for me. Which shell do you use, under bash it works ok.
Nov 1 '13 #2
rajujrk
107 100+
How did you make the script to run on bash? I am new to Shell Script programming

How did you make a script as bash?

Thanks
Raju
Nov 6 '13 #3
rski
700 Expert 512MB
you put
Expand|Select|Wrap|Line Numbers
  1. #!/bin/bash
  2.  
at the beggining of the script. make sure that /bin/bash file exists, it may be under different location in your system.
Nov 6 '13 #4
rajujrk
107 100+
I already given, still I am getting the same output.

One More info: I am running this script thru the software PUTTY from windows XP

Thanks
Raju
Nov 6 '13 #5
rski
700 Expert 512MB
Could you put here the script code? What OS do you use (Linux/Unix, what Linux?)
Nov 6 '13 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Laura P | last post by:
Hi, I wasn't sure whether this should be posted in the Java are or in a Solaris thread, so I shall post it in both. Sorry for the duplication. I am new to Solaris and am having trouble...
3
by: FPGA05 | last post by:
Hello All, I am developing a small application in which I would need a C++ application to read the output from a shell script. A shell script keeps looking for user inputs and once the user...
2
by: mesum98 | last post by:
Hi, I have a python script which creates a csv file using following method def printOutInformation(self): if self.orderby == 'r': ...
2
by: Gerard Flanagan | last post by:
Hello, I have a third party shell script which updates multiple environment values, and I want to investigate (and ultimately capture to python) the environment state after the script has run....
4
by: smashzone | last post by:
Hi all, Can anyone help me with a script to produce an output file of a "df -m" command with ";" seperators. I assume its very easy but I know nothing about Linux/Unix (I'm a newbie) That is: ...
2
by: jonathan184 | last post by:
Hi I am trying to create a shell script that will look for a contracthead file first and if the contract head file does not exist on day1 exit script. Now on day2 if contracthead exists or...
1
by: newfresher | last post by:
Hi, I want to write a shell script which ll access the folder, open it and read the series of text/sql files their one after another, in it. After reading one text/sql file, commands their in...
1
by: sandy2481 | last post by:
Hi Friends, I'm a beginner in perl. Can anyone please provide me with a perl code to read a HTML file and write into excel file. Regards, Sandy
7
by: Samuel A. Falvo II | last post by:
I have a shell script script.sh that launches a Java process in the background using the &-operator, like so: #!/bin/bash java ... arguments here ... & In my Python code, I want to invoke...
0
by: ndedhia1 | last post by:
I am having trouble loading a property file and keep getting this error when running my shell script that loads and runs my jar files, etc: no property file loaded, using defaults......
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.