Get full output of curl shell command in org-modesteemCreated with Sketch.

in org-mode •  6 years ago  (edited)

At present (<2018-05-10 Thu 21:28:48 UTC+08:00>) there are three solutions. Although the final results are slightly different, they are similar but do not affect the final result.

org-babel-execute-src-block

It was first mentioned in this unsolved question
https://www.reddit.com/r/orgmode/8ibv92
, but missing some header arguments.

Snapshot:

Org src block is shaped like:

#+BEGIN_SRC sh :session curl :results pp replace
curl --verbose bing.com
#+END_SRC

Results:

* Rebuilt URL to: bing.com/
*   Trying 13.107.21.200...
* TCP_NODELAY set
0)
GET / HTTP/1.1
Host: bing.com
User-Agent: curl/7.58.0
Accept: */*
< HTTP/1.1 301 Moved Permanently
< Location: http://cn.bing.com/
< Server: Microsoft-IIS/10.0
< X-MSEdge-Ref: Ref A: 5FBE8FC6F1284934AA83DBD4A06DCABC Ref B: HKGEDGE0310 Ref C: 2018-05-10T13:06:45Z
< Date: Thu, 10 May 2018 13:06:44 GMT
< Content-Length: 0
<
0 to host bing.com left intact

M-x shell-command with C-u prefix

The interactive way:

  1. Create a blank example block
    1. insert "<e" snippet
    2. expand by TAB
      (org-cycle)
      
  2. Edit block
    (org-edit-special)
    
  3. Run shell-command
    1. C-u
    2. M-x shell-command
    3. curl --verbose bing.com
  4. Exit block
    (org-edit-src-exit)
    

Results:

* Rebuilt URL to: bing.com/
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                 Dload  Upload   Total   Spent    Left  Speed

  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0*   Trying 13.107.21.200...
* TCP_NODELAY set
* Connected to bing.com (13.107.21.200) port 80 (#0)
> GET / HTTP/1.1
> Host: bing.com
> User-Agent: curl/7.58.0
> Accept: */*
>
< HTTP/1.1 301 Moved Permanently
< Location: http://cn.bing.com/
< Server: Microsoft-IIS/10.0
< X-MSEdge-Ref: Ref A: 2601B9A705A647898C784B84AB19F75B Ref B: HKGEDGE0317 Ref C: 2018-05-10T12:53:27Z
< Date: Thu, 10 May 2018 12:53:27 GMT
< Content-Length: 0
<

  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
* Connection #0 to host bing.com left intact

shell-command-to-string

Org src block is shaped like:

#+BEGIN_SRC emacs-lisp :results replace
(shell-command-to-string "curl --verbose bing.com")
#+END_SRC

Results:

* Rebuilt URL to: bing.com/
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                 Dload  Upload   Total   Spent    Left  Speed

  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0*   Trying 13.107.21.200...
* TCP_NODELAY set
* Connected to bing.com (13.107.21.200) port 80 (#0)
> GET / HTTP/1.1
> Host: bing.com
> User-Agent: curl/7.58.0
> Accept: */*
>
< HTTP/1.1 301 Moved Permanently
< Location: http://cn.bing.com/
< Server: Microsoft-IIS/10.0
< X-MSEdge-Ref: Ref A: 320F849357A74CFFBE25A87CF3274F59 Ref B: HKGEDGE0319 Ref C: 2018-05-10T13:08:14Z
< Date: Thu, 10 May 2018 13:08:13 GMT
< Content-Length: 0
<

  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
* Connection #0 to host bing.com left intact
Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!