PHP fopen and fread proper format - fopen

So i'm trying to get a fopen and fread statement to display logs and each entry is formatted in a new line, how can I get my code to go in the same format as the .txt,
.txt :
[2014/1/19 - 22:49:37] Josh (IP:174.101.171.132) has edited auction 0 expire time to 60
[2014/1/19 - 22:49:43] Josh (IP:174.101.171.132) has edited auction 0 enabled to 1 (Enabled)
[2014/1/19 - 22:49:51] Josh (IP:174.101.171.132) has edited auction 0 item description to Free House
[2014/1/19 - 22:49:59] Josh (IP:174.101.171.132) has edited auction 0 starting bid to 5000000
[2014/1/19 - 22:50:31] Josh (IP:174.101.171.132) has edited auction 0 enabled to 0 (disabled)
[2014/1/19 - 22:50:37] Josh (IP:174.101.171.132) has edited auction 0 item description to none
[2014/1/19 - 22:50:45] Josh (IP:174.101.171.132) has edited auction 0 item description to (none)
[2014/1/19 - 22:50:50] Josh (IP:174.101.171.132) has edited auction 0 starting bid to 0
[2014/1/20 - 11:40:09] Josh (IP:174.101.171.132) has edited auction 0 item description to Testing House
[2014/1/20 - 11:40:14] Josh (IP:174.101.171.132) has edited auction 0 expire time to 1
[2014/1/20 - 11:40:18] Josh (IP:174.101.171.132) has edited auction 0 starting bid to 1
[2014/1/20 - 11:40:21] Josh (IP:174.101.171.132) has edited auction 0 enabled to 1 (Enabled)
PHP Return:
[2014/1/19 - 22:49:37] Josh (IP:174.101.171.132) has edited auction 0 expire time to 60 [2014/1/19 - 22:49:43] Josh (IP:174.101.171.132) has edited auction 0 enabled to 1 (Enabled) [2014/1/19 - 22:49:51] Josh (IP:174.101.171.132) has edited auction 0 item description to Free House [2014/1/19 - 22:49:59] Josh (IP:174.101.171.132) has edited auction 0 starting bid to 5000000 [2014/1/19 - 22:50:31] Josh (IP:174.101.171.132) has edited auction 0 enabled to 0 (disabled) [2014/1/19 - 22:50:37] Josh (IP:174.101.171.132) has edited auction 0 item description to none [2014/1/19 - 22:50:45] Josh (IP:174.101.171.132) has edited auction 0 item description to (none) [2014/1/19 - 22:50:50] Josh (IP:174.101.171.132) has edited auction 0 starting bid to 0 [2014/1/20 - 11:40:09] Josh (IP:174.101.171.132) has edited auction 0 item description to Testing House [2014/1/20 - 11:40:14] Josh (IP:174.101.171.132) has edited auction 0 expire time to 1 [2014/1/20 - 11:40:18] Josh (IP:174.101.171.132) has edited auction 0 starting bid to 1 [2014/1/20 - 11:40:21] Josh (IP:174.101.171.132) has edited auction 0 enabled to 1 (Enabled)

The following
$lines = file('/path/to/file');
gives you an array where every element is a line of the file.
http://php.net/file

use fgets
fgets reads one line of text from the file. If you are outputting it to an HTML stream, the output one line at a time and add <BR> after each line. Or, just use <pre></pre> tags and output the entire file as is.

Related

How to filter tags to be included/excluded in a clocktable

I'd like to set up a clocktable where I can specify what tags to include and exclude.
I've tried the below. I've tried with and without double quotes, using + and &, and using :match as well as :tags, nothing seems to work. From the manual it seems that :match should do exactly what I want, but it just includes everything no matter what I do.
#+TAGS: { billable(a) notes(o) travel(b) }
#+BEGIN: clocktable :scope file :tags +"billable"+"notes"-"travel"
#+CAPTION: Clock summary at [2019-09-20 Fri 21:49]
| Headline | Time |
|--------------+--------|
| *Total time* | *1:00* |
|--------------+--------|
| Session | 1:00 |
#+END:
* Session :billable:
:LOGBOOK:
CLOCK: [2019-09-19 Thu 17:30]--[2019-09-19 Thu 18:30] => 1:00
:END:
* Notes :notes:
:LOGBOOK:
CLOCK: [2019-09-19 Thu 18:30]--[2019-09-19 Thu 18:45] => 0:15
:END:
* Travel :travel:
:LOGBOOK:
CLOCK: [2019-09-19 Thu 18:45]--[2019-09-19 Thu 18:55] => 0:10
:END:
I discovered the correct syntax is to have all tags within a single double quote.
:tags "billable|notes-travel"
Since org-mode version 9.2, the :tags argument adds a column with tags when set to t. The argument :match has the old functionality that matches specific tags.
From the changelog,
The :match (renamed from :tags) option allows to limit clock entries to those matching a todo-tags matcher.
The old :tags option can be set to t to display a headline's tags in a dedicated column.

Get IRC Command response

I want to run an IRC Command, and get the response for it for bots.
Is there any way to do this?
for example, I want to get the result of "NAMES #channel" or "WHO #channel u"
You have to wait for 353 and 366 replies (for NAMES), and 354 and 315 for WHO.
For instance, when using NAMES:
(outgoing) NAMES #channel
(incoming) :wilhelm.freenode.net 353 botnick = #channel :user1 user2 user3 #user4
(incoming) :wilhelm.freenode.net 366 botnick #channel :End of /NAMES list.
And similarily when using WHO:
(outgoing) WHO #channel
(incoming) :wilhelm.freenode.net 354 botnick #channel ident host sendak.freenode.net nick H 0 nick :realname
[…]
(incoming) :wilhelm.freenode.net 315 botnick #channel :End of /WHO list.

Powershell script to search text file and output multiple lines in order

My source file has multiple serial interfaces. I want to simply output each serial line "Serial0/2/0:0" and then the following drops, aborts, etc. on the next lines in the output file under each Serial interface. So far I have this:
get-childitem show-int.log | select-string -pattern drops | foreach {$_.line}
And simply run it with > todays-date. I am a network engineer so forgive how bad I am at ps. I've tried google and putting the many items in quotes but nothing works to my satisfaction.
Serial0/2/0:0 is up, line protocol is up
Hardware is DSX1
MTU 1500 bytes, BW 1536 Kbit/sec, DLY 20000 usec,
reliability 255/255, txload 33/255, rxload 133/255
Encapsulation PPP, LCP Open, multilink Open
Link is a member of Multilink bundle Multilink1, loopback not set
Keepalive set (10 sec)
Last input 00:00:00, output 00:00:00, output hang never
Last clearing of "show interface" counters 1d18h
Input queue: 0/75/0/0 (size/max/drops/flushes); Total output drops:
381
Queueing strategy: fifo
Output queue: 0/40 (size/max)
5 minute input rate 805000 bits/sec, 188 packets/sec
5 minute output rate 200000 bits/sec, 153 packets/sec
8320454 packets input, 2999426407 bytes, 0 no buffer
Received 0 broadcasts (0 IP multicasts)
22 runts, 0 giants, 0 throttles
30 input errors, 29 CRC, 0 frame, 1 overrun, 0 ignored, 0 abort
7629921 packets output, 1268811436 bytes, 0 underruns
0 output errors, 0 collisions, 4294967295 interface resets
0 unknown protocol drops
0 output buffer failures, 0 output buffers swapped out
7 carrier transitions
Not precise, but easy:
Get-Content show-int.log | select-string 'Serial0/2/0:0' -Context 0,10

SED and/or awk help required

I am using openvms but have access to versions of aWk and /or sed on this platform. Wondered if anyone can help with a text file processing job.
My file looks like
START-OF-DATA
Stock ID|XYZ
START-TIME 11:30
END_TIME 12:30
11:31|BID|12.5|ASK|12.7
11:34|BID|12.6|ASK|12.7
END-OF-DATA
START-OF-DATA
Stock ID|ABC
START-TIME 11:30
END_TIME 12:30
11:40|BID|.245|ASK|.248
11:34|BID|.246|ASK|.249
END-OF-DATA
Basically I want to pre-pend the BID/ASK data records with the Stock ID so the above file should look like
START-OF-DATA
Stock ID|XYZ
START-TIME 11:30
END_TIME 12:30
XYZ|11:31|BID|12.5|ASK|12.7
XYZ|11:34|BID|12.6|ASK|12.7
END-OF-DATA
START-OF-DATA
Stock ID|ABC
START-TIME 11:30
END_TIME 12:30
ABC|11:40|BID|.245|ASK|.248
ABC|11:34|BID|.246|ASK|.249
END-OF-DATA
Can any one help ?
Like this:
awk -F'|' 'BEGIN{OFS="|"} /^Stock/{S=$2} /BID|ASK/{print S,$0}' file
Explanation (with thanks to Olivier Dulac)
It updates "S" variable each time it encounters a line stating with "Stock", and then prepends S to lines CONTAINING "BID" or "ASK" (using | as a separator for reading and for outputting).
try this:
awk -F'|' 'NF==2{pre=$2}NF>2{$0=pre FS $0}7' file
it works for the given example.
Using awk
awk '/Stock ID/{s=$2}/BID|ASK/{$0=s FS $0}1' FS=\| file
START-OF-DATA
Stock ID|XYZ
START-TIME 11:30
END_TIME 12:30
XYZ|11:31|BID|12.5|ASK|12.7
XYZ|11:34|BID|12.6|ASK|12.7
END-OF-DATA
START-OF-DATA
Stock ID|ABC
START-TIME 11:30
END_TIME 12:30
ABC|11:40|BID|.245|ASK|.248
ABC|11:34|BID|.246|ASK|.249
END-OF-DATA
This might work for you (GNU sed):
sed -r '/Stock ID/h;/BID|ASK/{G;s/(.*)\n.*\|(.*)/\2|\1/}' file
Save the Stock ID in the hold space and prepend it to records containing BID or ASK.

What am I doing wrong while importing the following data into sas

I am trying to import certain data into my SAS datset using this piece of code:
Data Names_And_More;
Infile 'C:\Users\Admin\Desktop\Torrent Downloads\SAS 9.1.3 Portable\Names_and_More.txt';
Input Name & $20.
Phone : $20.
Height & $10.
Mixed & $10.;
run;
The data in the file is as below:
Roger Cody (908)782-1234 5ft. 10in. 50 1/8
Thomas Jefferson (315)848-8484 6ft. 1in. 23 1/2
Marco Polo (800)123-4567 5Ft. 6in. 40
Brian Watson (518)355-1766 5ft. 10in 89 3/4
Michael DeMarco (445)232-2233 6ft. 76 1/3
I have been trying to learn SAS and while going through Ron Cody's book Learning SAS by example,I found to import the kind of data above, we can use 'the ampersand (&) informat modifier. The ampersand, like the colon,says to use the supplied informat, but the delimiter is now two or more blanks instead of just one.' (Ron's words, not mine). However, while importing this the result (dataset) is as follows:
Name Phone Height Mixed
Roger Cody (908)782- Thomas Jefferson Marco Polo
Also, for further details the SAS log is as follows:
419 Data Names_And_More;
420 Infile 'C:\Users\Admin\Desktop\Torrent Downloads\SAS 9.1.3 Portable\Names_and_More.txt';
421 Input Name & $20.
422 Phone : $20.
423 Height & $10.
424 Mixed & $10.
425 ;run;
NOTE:
The infile 'C:\Users\Admin\Desktop\Torrent Downloads\SAS 9.1.3 Portable\Names_and_More.txt' is:
File Name=C:\Users\Admin\Desktop\Torrent Downloads\SAS 9.1.3 Portable\Names_and_More.txt,
RECFM=V,LRECL=256
NOTE:
LOST CARD.
Name=Brian Watson (518)35 Phone=Michael Height=DeMarco (4 Mixed= ERROR=1 N=2
NOTE: 5 records were read from the infile 'C:\Users\Admin\Desktop\Torrent Downloads\SAS 9.1.3
Portable\Names_and_More.txt'.
The minimum record length was 37.
The maximum record length was 47.
NOTE: SAS went to a new line when INPUT statement reached past the end of a line.
NOTE: The data set WORK.NAMES_AND_MORE has 1 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.17 seconds
cpu time 0.14 seconds
I am looking for some help with this one. It'd be great if someone can explain what exactly is happening, what am I doing wrong and how to correct this error.
Thanks
The answer is in the explanation in Ron Cody's book. & means you need two spaces to separate varaibles; so you need a second space after the name (and other fields with &).
Wrong:
Roger Cody (908)782-1234 5ft. 10in. 50 1/8
Right:
Roger Cody (908)782-1234 5ft. 10in. 50 1/8