Browse Source

Added doc for pfile

Alois Mahdal 11 years ago
parent
commit
cf707b10d3
1 changed files with 40 additions and 0 deletions
  1. 40
    0
      README.md

+ 40
- 0
README.md View File

@@ -73,6 +73,46 @@ Make executable script for you and heat up vim.  Accepts filename as parameter.
73 73
 4.  try to heat up `vim` or `editor` for you.
74 74
 
75 75
 
76
+### pfile ###
77
+
78
+Wrapper around *file* utility that reads STDIN, stores it in a temporary file
79
+(using Python's *tmpfile.mkstemp*),calls the utility on it and returns output
80
+(and of course, deletes the tmpfile afterwards).
81
+
82
+This is useful in cases like when debugging a HTTP server with utility like
83
+*curl*, and when we don't want to see the actual output, yet still want to know
84
+what it looks like.  Using pfile on pipe, we can easily combine the power
85
+of *file* with the simplicity of *curl*:
86
+
87
+
88
+    us@here:~$ curl -4 -v http://www.example.com/ | pfile
89
+    * About to connect() to www.example.com port 80 (#0)
90
+    *   Trying 1.2.3.4...
91
+    * Connected to www.example.com (1.2.3.4) port 80 (#0)
92
+    > GET / HTTP/1.1
93
+    > User-Agent: curl/7.26.0
94
+    > Host: www.example.com
95
+    > Accept: */*
96
+    >
97
+    * additional stuff not fine transfer.c:1037: 0 0
98
+    * HTTP 1.1 or later with persistent connection, pipelining supported
99
+    < HTTP/1.1 200 OK
100
+    < Date: Tue, 22 Oct 2013 10:41:28 GMT
101
+    < Server: Apache/2.2.22 (Debian)
102
+    < Last-Modified: Wed, 17 Jul 2013 17:22:00 GMT
103
+    < Accept-Ranges: bytes
104
+    < Content-Length: 123
105
+    < Vary: Accept-Encoding
106
+    < Content-Type: text/html
107
+    <
108
+    { [data not shown]
109
+    100    123 100    123   0     0   1169      0 --:--:-- --:--:-- --:--:--  1369
110
+    * Connection #0 to host www.example.com left intact
111
+    * Closing connection #0
112
+    /tmp/tmplZbSB4: ASCII text
113
+    us@here:~$
114
+
115
+
76 116
 ### pl2yml, yml2pl ###
77 117
 
78 118
 Simple scripts to read YAML/Perl data structure from a file and dump it in