Sponsored Content
Top Forums Shell Programming and Scripting [Solved] Need Help in reading Response file Post 302890947 by wisecracker on Sunday 2nd of March 2014 05:58:17 PM
Old 03-02-2014
Just about to HTH...

What will be the maximum number of lines that ADDRESS will span?
I only need the maximum at this point...

Will continue tomorrow.

HTH.

---------- Post updated at 10:58 PM ---------- Previous update was at 10:38 PM ----------

Decided to stay up and quickly do a test piece...

This should take into account multiple newlines in the ADDRESS section:-
Code:
#/bin/bash
# multi_vars.sh
ifs_str="$IFS"
IFS="
"
echo 'NAME=SAM
DOB=01/01/1980
ADDRESS=
7658 James Street
NewYork
0000' > /tmp/multi_vars.txt
read -d '' -r text < /tmp/multi_vars.txt
echo ""
echo "$text"
echo ""
echo "Start of placing substrings into variables..."
echo ""
var_array=($text)
n=0
while true
do
	if [ $n -ge ${#var_array[@]} ]
	then
		break
	fi
	subtext="${var_array[$n]}"
	if [ "${subtext:0:4}" == "NAME" ]
	then
		name=${var_array[0]}
	fi
	if [ "${subtext:0:3}" == "DOB" ]
	then
		dob=${var_array[1]}
	fi
	if [ "${subtext:0:7}" == "ADDRESS" ]
	then
		address=$address${var_array[2]}
		for m in $( seq 3 1 $[ ( ${#var_array[@]} - 2 ) ] )
		do
			address=$address"${var_array[$m]}. "
		done
	fi
	number=${var_array[$n]}
	n=$[ ( $n + 1 ) ]
done
echo "$name"
echo "$dob"
echo "$address"
echo "$number"
echo ""
echo "DONE!"
echo ""
IFS="$ifs_str"
exit 0

Results:-
Code:
Last login: Sun Mar  2 22:39:26 on ttys000
AMIGA:barrywalker~> ./multi_vars.sh

NAME=SAM
DOB=01/01/1980
ADDRESS=
7658 James Street
NewYork
0000

Start of placing substrings into variables...

NAME=SAM
DOB=01/01/1980
ADDRESS=7658 James Street. NewYork. 
0000

DONE!

AMIGA:barrywalker~> _

HTH, goodnight folks...
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Reading response from server

I am trying to write a korn shell script which posts commands to a server and read the response back from the server. Any idea how I can read the servers response? I have tried doing the following: ( LOGIN:xxxxx command to server read ANSWER echo $ANSWER >file1... (4 Replies)
Discussion started by: frustrated1
4 Replies

2. UNIX for Advanced & Expert Users

ssh error: Error reading response length from authentication socket

Hi - I am getting the error `Error reading response length from authentication socket' when I ssh from my cluster to another cluster, and then back to my cluster. It doesn't seem to affect anything, but it's just annoying that it always pops up and tends to confuse new users of the cluster. I... (1 Reply)
Discussion started by: cpp6f
1 Replies

3. Shell Programming and Scripting

[Solved] Problem in reading a file line by line till it reaches a white line

So, I want to read line-by-line a text file with unknown number of files.... So: a=1 b=1 while ; do b=`sed -n '$ap' test` a=`expr $a + 1` $here do something with b etc done the problem is that sed does not seem to recognise the $a, even when trying sed -n ' $a p' So, I cannot read... (3 Replies)
Discussion started by: hakermania
3 Replies

4. Shell Programming and Scripting

SOLVED: reading config file in a perl script

Hi! I have a need to do this in Perl. script.pl -config file The script would be doing a wget/LWP on a URL which is defined in the config file. So when I run the script it should return either one of these conditions - 1) OK with exit status 0. Should also print "wget URL" 2)... (6 Replies)
Discussion started by: jacki
6 Replies

5. Shell Programming and Scripting

[solved] merging two files and writing to another file- solved

i have two files as file1: 1 2 3 file2: a b c and the output should be: file3: 1~a 2~b 3~c (1 Reply)
Discussion started by: mlpathir
1 Replies

6. Shell Programming and Scripting

[Solved] delete line from file1 by reading from file2

Hi All, I have to arrange one of the text file by deleting specific lines. cat file1.txt 3595 3595 -0.00842773 -0.0085077 0.00368851 12815 12815 -0.00929239 0.00439785 0.0291697 3747 3747 -0.00974353 0.00228922 0.0225058 3574 3574 -0.00711399 -0.00315748 0.0141206 .... 12734... (7 Replies)
Discussion started by: senayasma
7 Replies

7. Shell Programming and Scripting

[Solved] Reading the last word in a file from a script

Hello everybody, My first time here and my english is not very good I hope you understand me. I'm trying to read a file that contains two zip archive names. Here my file content is: package1.zip package2.zip At the end of the line there is a \n character. I read this file from a... (2 Replies)
Discussion started by: Aurea
2 Replies

8. Programming

[Solved] Problem with fork() while reading files

Good evening everyone. I have my finals and I'm facing a problem: I have a for cycle that is supposed to fork 2 children but somehow it forks only the first one. What am I doing wrong ? #include <fcntl.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <time.h>... (5 Replies)
Discussion started by: pfpietro
5 Replies

9. UNIX for Dummies Questions & Answers

[Solved] Reading Array And Send An Email

I am trying to find an example for reading an array instead of reading a file and send out an email in ksh. Can you please help is that possible? Algorithm #!/bin/ksh i=0 set -A ARR if then let i=$ ARR="A does n't match with B" fi if then let i=$ ARR="P does n't match with Q"... (11 Replies)
Discussion started by: Ariean
11 Replies

10. Shell Programming and Scripting

Problem reading terminal response string from Zsh

Note: This posting is related to my posting at bash - Reading answer to control string sent to xterm - Stack Overflow , but I could get there a solution only for bash. I can use that solution, but for curiosity, I wonder, whether I could do this in Zsh as well. The problem is to send a (Posix-)... (6 Replies)
Discussion started by: rovf
6 Replies
BGPD(8) 							   Version 0.88 							   BGPD(8)

NAME
bgpd - a BGPv4, BGPv4+, BGPv4- routing engine for use with Zebra SYNOPSIS
bgpd [ -dhpPv ] [ -f config-file ] [ -i pid-file ] [ -p bgp-port-number ] [ --bgp_port=port-number ] [ -P vty-port-number ] DESCRIPTION
bgpd is a routing component that works with the zebra routing engine. OPTIONS
-d, --daemon Runs in daemon mode, forking and exiting from tty. -f, --config-file config-file Specifies the config file to use for startup. If not specified this option will likely default to /usr/local/etc/bgpd.conf. -h, --help A brief message. -i, --pid_file pid-file When bgpd starts its process idenifier is written to pid-file. The init system uses the recorded PID to stop or restart bgpd. The likely default is /var/run/bgpd.pid. -p, --bgp_port=port Set the port that bgpd will listen to for bgp data. -P, --vty_port port-number Specify the port that the bgpd VTY will listen on. This defaults to 2605, as specified in /etc/services. -r, --retain When the program terminates, retain routes added by bgpd. -v, --version Print the version and exit. COMMANDS
router zebra -- (Move routes into kernel table) router bgp [AS-NUMBER] bgp router-id [BGP-ROUTER-ID] network [NETWORK] area [BGP-AREA-ID] no network [NETWORK] aggregate-address [NETWORK] neighbor [PEER-IP-ADDRESS] remote-as [REMOTE-AS] neighbor [PEER-IP-ADDRESS] version [ 4 | 4+ | 4- ] neighbor [PEER-IP-ADDRESS] description no neighbor [PEER-IP-ADDRESS] description neighbor [PEER-IP-ADDRESS] route-map [in | out] neighbor [PEER-IP-ADDRESS] distribute-list [in | out] neighbor [PEER-IP-ADDRESS] next-hop-self neighbor [PEER-IP-ADDRESS] weight [WEIGHT] neighbor [PEER-IP-ADDRESS] default-originate neighbor [PEER-IP-ADDRESS] ebgp-multihop neighbor [PEER-IP-ADDRESS] shutdown no neighbor [PEER-IP-ADDRESS] shutdown clear ip bgp [PEER-IP-ADDRESS] show ip bgp [NETWORK] show ip bgp reg-exp [AS-REGEXP] show ip bgp summary show ip bgp neighbor [PEER-IP-ADDRESS] show ip bgp route show debug debug bgp debug event debug update debug keepalive no debug event no debug update no debug keepalive FILES
/usr/local/sbin/bgpd The default location of the bgpd binary. /usr/local/etc/bgpd.conf The default location of the bgpd config file. $(PWD)/bgpd.log If the bgpd process is config'd to output logs to a file, then you will find this file in the directory where you started bgpd. WARNING
This man page is intended as a quick reference for command line options, and for config file commands. The definitive document is the Info file zebra. DIAGNOSTICS
The bgpd process may log to standard output, to a VTY, to a log file, or through syslog to the system logs. bgpd supports many debugging options, see the Info file, or the source for details. SEE ALSO
References to other related man pages: ripd(8), ripngd(8), ospfd(8), ospf6d(8), zebra(8), vtysh(1) BUGS
bgpd eats bugs for breakfast. If you have food for the maintainers try <bug-zebra@gnu.org> AUTHOR
[S] See <www.zebra.org>, or the Info file for an accurate list of authors. Zebra Beast - BGPD July 2000 BGPD(8)
All times are GMT -4. The time now is 04:08 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy