Sponsored Content
Full Discussion: How to parse..
Top Forums Shell Programming and Scripting How to parse.. Post 35814 by oombera on Wednesday 7th of May 2003 01:35:56 PM
Old 05-07-2003
You could use the substr function of awk:

awk '{ print substr ($0, length ($0) - 5, 4)}' someFile

or:

port="Attempting to contact (ADDRESS=(PROTOCOL=TCP)(Host=chamar)(Port=1541))"
echo $port | awk '{ print substr ($0, length ($0) - 5, 4)}'
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Parse

Does anybody know how do we parse a file (ex. SIF file) into a delimited text file in UNIX? (7 Replies)
Discussion started by: nguda
7 Replies

2. UNIX for Advanced & Expert Users

Parse error

hi,:) onsider the followinf two lines J="$(scriptbc -p 8 $I / \(12 \* 100 \) )" N="$(( $L * 12 ))" In the first line I put \ before * like \* and its working fine. But in the second line if put \ before * i am getting parse error. What might be the reason?Any idea pls. cheers RRK (1 Reply)
Discussion started by: ravi raj kumar
1 Replies

3. Shell Programming and Scripting

Need help to parse the file

# Start "ABC" SFFd 0 4 Time SFFT 4 8 {Sec} User SFFTimeVal 12 8 {Sec} # Start "CP" SFFT ... (3 Replies)
Discussion started by: navsharan
3 Replies

4. Shell Programming and Scripting

Parse

I need a script that will always return an engine of table, which not depends on the table structure. I need it to be done exactly from the "show create table ..." statement. If there is a easiest way, except "show table status", please write. mysql -u root db -sBe "show create table... (1 Reply)
Discussion started by: mirusnet
1 Replies

5. Shell Programming and Scripting

Perl Parse

Hi I'm writing simple perl script to parse the ftp log as below: Local directory now /home/user/testing 227 Entering Passive Mode (192,254,19,34,8,228). 125 Data connection already open; Transfer starting. 09-25-09 02:33PM 25333629 abc.tar 09-14-09 12:50PM 18015752... (1 Reply)
Discussion started by: netxus
1 Replies

6. Shell Programming and Scripting

How to Parse a Prompt?

On the command, when I type in certain commands, they will display a prompt waiting for some input. When I type in the requested input, it will display the info I requested. For example, if I enter the telnet command, it will display a telnet prompt and wait for me to enter something. I... (1 Reply)
Discussion started by: april
1 Replies

7. Shell Programming and Scripting

Parse 2 or more files into one.

Hi, I have a really simple question...I think. I want to be able to parse two or more files into one by reading the first record from each file into new file then go back to the first file and start reading the second record in from each file into new file and so on. I am new to using awk and am... (5 Replies)
Discussion started by: qray2011
5 Replies

8. Shell Programming and Scripting

Parse

Attached file is parsed so that only the three columns result. DACH1 occurs 34 times with an average of 0.881541 NEB occurs 159 times with an average of 0.837628 LTBP1 occurs 46 times with an average of 0.748722 parse result: output.txt (the text is removed and the xxx is seperated in a... (6 Replies)
Discussion started by: cmccabe
6 Replies

9. Shell Programming and Scripting

Parse html

I downloaded source code using: wget -qO- http://fulgentdiagnostics.com/test/clinical-exome/ | cat > flugentsource.txt Now I am trying to use sed to parse it to confirm a gene count. Basically, output (flugent.txt) all the gene names with a total count after them I'm not all that... (5 Replies)
Discussion started by: cmccabe
5 Replies

10. Programming

Parse with SQL

I am trying to parse a string using SQL but am too new and still learning. I have text in a control or field 685 that is variable, but always the same format. field 685 input arr 2q33.3q34(200,900,700-209,000,000)x2 xxx Desired output 2:200900700-209000000 Basically, the # after the... (2 Replies)
Discussion started by: cmccabe
2 Replies
SOCKET_RECV(3)								 1							    SOCKET_RECV(3)

socket_recv - Receives data from a connected socket

SYNOPSIS
int socket_recv (resource $socket, string &$buf, int $len, int $flags) DESCRIPTION
The socket_recv(3) function receives $len bytes of data in $buf from $socket. socket_recv(3) can be used to gather data from connected sockets. Additionally, one or more flags can be specified to modify the behaviour of the function. $buf is passed by reference, so it must be specified as a variable in the argument list. Data read from $socket by socket_recv(3) will be returned in $buf. PARAMETERS
o $socket - The $socket must be a socket resource previously created by socket_create(). o $buf - The data received will be fetched to the variable specified with $buf. If an error occurs, if the connection is reset, or if no data is available, $buf will be set to NULL. o $len - Up to $len bytes will be fetched from remote host. o $flags - The value of $flags can be any combination of the following flags, joined with the binary OR ( |) operator. Possible values for $flags +-------------+---------------------------------------------------+ | Flag | | | | | | | Description | | | | +-------------+---------------------------------------------------+ | | | | MSG_OOB | | | | | | | Process out-of-band data. | | | | | | | | MSG_PEEK | | | | | | | Receive data from the beginning of the receive | | | queue without removing it from the queue. | | | | | | | |MSG_WAITALL | | | | | | | Block until at least $len are received. However, | | | if a signal is caught or the remote host discon- | | | nects, the function may return less data. | | | | | | | |MSG_DONTWAIT | | | | | | | With this flag set, the function returns even if | | | it would normally have blocked. | | | | +-------------+---------------------------------------------------+ RETURN VALUES
socket_recv(3) returns the number of bytes received, or FALSE if there was an error. The actual error code can be retrieved by calling socket_last_error(3). This error code may be passed to socket_strerror(3) to get a textual explanation of the error. EXAMPLES
Example #1 socket_recv(3) example This example is a simple rewrite of the first example from "Examples" to use socket_recv(3). <?php error_reporting(E_ALL); echo "<h2>TCP/IP Connection</h2> "; /* Get the port for the WWW service. */ $service_port = getservbyname('www', 'tcp'); /* Get the IP address for the target host. */ $address = gethostbyname('www.example.com'); /* Create a TCP/IP socket. */ $socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); if ($socket === false) { echo "socket_create() failed: reason: " . socket_strerror(socket_last_error()) . " "; } else { echo "OK. "; } echo "Attempting to connect to '$address' on port '$service_port'..."; $result = socket_connect($socket, $address, $service_port); if ($result === false) { echo "socket_connect() failed. Reason: ($result) " . socket_strerror(socket_last_error($socket)) . " "; } else { echo "OK. "; } $in = "HEAD / HTTP/1.1 "; $in .= "Host: www.example.com "; $in .= "Connection: Close "; $out = ''; echo "Sending HTTP HEAD request..."; socket_write($socket, $in, strlen($in)); echo "OK. "; echo "Reading response: "; $buf = 'This is my buffer.'; if (false !== ($bytes = socket_recv($socket, $buf, 2048, MSG_WAITALL))) { echo "Read $bytes bytes from socket_recv(). Closing socket..."; } else { echo "socket_recv() failed; reason: " . socket_strerror(socket_last_error($socket)) . " "; } socket_close($socket); echo $buf . " "; echo "OK. "; ?> The above example will produce something like: <h2>TCP/IP Connection</h2> OK. Attempting to connect to '208.77.188.166' on port '80'...OK. Sending HTTP HEAD request...OK. Reading response: Read 123 bytes from socket_recv(). Closing socket...HTTP/1.1 200 OK Date: Mon, 14 Sep 2009 08:56:36 GMT Server: Apache/2.2.3 (Red Hat) Last-Modified: Tue, 15 Nov 2005 13:24:10 GMT ETag: "b80f4-1b6-80bfd280" Accept-Ranges: bytes Content-Length: 438 Connection: close Content-Type: text/html; charset=UTF-8 OK. PHP Documentation Group SOCKET_RECV(3)
All times are GMT -4. The time now is 03:48 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy