Reading a value from the configuration file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Reading a value from the configuration file
# 8  
Old 02-16-2009
Quote:
Originally Posted by yoursdavinder
I am using a windows editor
Remove the CR's with:

Code:
tr -d '\r' < file > temp
mv temp file

Regards
# 9  
Old 02-16-2009
Quote:
Originally Posted by Franklin52
Remove the CR's with:

Code:
tr -d '\r' < file > temp
mv temp file

Regards
I did not get you...CR's?? Sorry I am new to Unix...
# 10  
Old 02-16-2009
Dos/windows editors place a line feed and a carriage return character at the end of each line of a text file, but Unix uses only a line feed character.
The code is to get rid of the carriage return.

Regards
# 11  
Old 02-16-2009
Quote:
Originally Posted by Franklin52
Dos/windows editors place a line feed and a carriage return character at the end of each line of a text file, but Unix uses only a line feed character.
The code is to get rid of the carriage return.

Regards
Got your point but I am not able to get where and how to use it in my code... Smilie
# 12  
Old 02-16-2009
You don't have to use it in your code but on the UNIX command line. Alternatively, tell your editor to save the file in UNIX encoding (almost all Non-MS editors can do that)
# 13  
Old 02-16-2009
Quote:
Originally Posted by pludi
You don't have to use it in your code but on the UNIX command line. Alternatively, tell your editor to save the file in UNIX encoding (almost all Non-MS editors can do that)
Thanks alot for your help but sorry I am still confused and not getting it Smilie
# 14  
Old 02-16-2009
The lines in text files (including any script language) are separated with a line terminator (called EOL [End Of Line] in C++ for example). But not every OS uses the same kind. DOS/Windows uses 2 characters '\r' (Control character "Carriage Return") and '\n' (Control character "Line Feed"). UNIX uses just the '\n' (Line Feed) character. MacOS uses '\r'.
Since you wrote and saved your script on Windows, the default setting of your editor probably placed the two characters '\r' and '\n' at the end of every line, instead of only '\n', which UNIX would expect. In order to get your file into a format that UNIX will understand properly you have two options:
  1. Upload your file to the UNIX server, and on the command line enter
    Code:
    # tr -d '\r' < Country_Sample.sh > Country_Sample_new.sh

    and try running the new file.
  2. Dig through your editors settings and see if it's possible to change the default line terminator from Windows style to UNIX style. (This isn't possible with Notepad or Write)

Note: The two characters Carriage Return and Line Feed come from a time long long ago, when output was still done on needle printers instead of monitors. Carriage Return told the printer to move the printer head to it's leftmost position, Line Feed told it to advance the paper feed by one line
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

ksh Script, Reading A File, Grepping A File Contents In Another File

So I'm stumped. First... APOLOGIES... my work is offline in an office that has zero internet connectivity, as required by our client. If need be, I could print out my script attempts and retype them here. But on the off chance... here goes. I have a text file (file_source) of terms, each line... (3 Replies)
Discussion started by: Brusimm
3 Replies

2. Programming

Reading a router configuration file

Hello C specialists, I'm trying to write a program to read out a binary configuration file produced by a router. But the output of Name and Value is cryptic. What's going wrong? The structure of the binary file is very simple: struct nvram_tuple { char *name; char *value; ... (5 Replies)
Discussion started by: digidax
5 Replies

3. Shell Programming and Scripting

reading configuration files in bash. Best way?

Context: I have a random pin number generator script that reads a tab-delimited file containing a location and a count: eg., mansfield 30 tokyo 15 smithville 34It produces random PIN# in the amount specified by the number in the second column. Currently, I read the file... (7 Replies)
Discussion started by: Bubnoff
7 Replies

4. Shell Programming and Scripting

Configuration File

Hi I need a cofiguration file for my perl script... Suppose my perl script for counting total number of user is #!/usr/bin/perl -w $total_users; #To get how many users currently logged in########### $total_users=`who | wc -l`; print... (2 Replies)
Discussion started by: Harikrishna
2 Replies

5. Solaris

configuration file

Hi all-interesting forum. I am new with Solaris and i would like your advice on this: I am using a solaris 8 (ultra sparc IIi) workstation at my work,and i am trying to built another one exactly the same-so if the first one fails to have another one as backup. The problem is that the guy who... (1 Reply)
Discussion started by: ioa_pol
1 Replies

6. Shell Programming and Scripting

configuration file

i am trying to use a configuration file to FTP some files.. i am not sure how to call or use a configuration file in script. can anybody help (5 Replies)
Discussion started by: iamcool
5 Replies

7. Shell Programming and Scripting

Extracting data from text file based on configuration set in config file

Hi , a:) i have configuration file with pattren <Range start no>,<Range end no>,<type of records to be extracted from the data file>,<name of the file to store output> eg: myfile.confg 9899000000,9899999999,DATA,b.dat 9899000000,9899999999,SMS,a.dat b:) Stucture of my data file is... (3 Replies)
Discussion started by: suparnbector
3 Replies

8. Shell Programming and Scripting

Reading file names from a file and executing the relative file from shell script

Hi How can i dynamically read files names from a list file and execute them from a single shell script. Please help its urgent Thanks in Advance (4 Replies)
Discussion started by: anushilrai
4 Replies

9. Shell Programming and Scripting

How to create iso file according configuration file?

Hi folks, I have the following configuration file,which contains list of directories: /tmp> cat utils.conf Backup CPSync Change_Listener_Port Create_Database Deinstall Install_CPPlugin Project_migrator I have the following command in my ksh program: mkisofs -l -L -R -V ${PACK_NAME}... (1 Reply)
Discussion started by: nir_s
1 Replies

10. UNIX for Dummies Questions & Answers

Configuration file?

Anyone know which configuration file stores the users who are not permitted to use the at command? (2 Replies)
Discussion started by: Relykk
2 Replies
Login or Register to Ask a Question