0

I am trying to duplicate the following bash command in Elisp:

curl https://google.com | readability https://google.com

Here's what I have so far, but it doesn't capture the piping "| readability" part of it. How can I use Elisp to pass info that will be interpreted as "from stdin"?

(shell-command-to-string (format "readability %s \n%s" url htmls))
Drew
  • 75,699
  • 9
  • 109
  • 225
Webdev Tory
  • 319
  • 1
  • 10
  • 1
    I cant fathom how your elisp is supposed to be a replica for the original command. You're not calling `curl` *at all*, there's a newline in there for some reason... your question is very confusing. – phils Jun 05 '21 at 21:48
  • ```(shell-command-to-string (format "ls -lah %s | head -n%s" "~/" "10"))``` this works, so I'd say it's something with your call to readability, which I don't know what it is. – Muihlinn Jun 05 '21 at 21:59
  • https://emacs.stackexchange.com/tags/elisp/info – Drew Jun 05 '21 at 22:53
  • Cross-referencing with https://emacs.stackexchange.com/questions/66321/how-to-pipe-a-string-to-a-shell-command-in-elisp-rather-than-give-it-as-an-arg – phils Jun 15 '21 at 21:32

1 Answers1

2

The shell handles the pipelines, so there's no reason why the command you give shell-command-to-string can't include pipes.

(shell-command-to-string "curl 'https://google.com' 2>/dev/null | wc")
phils
  • 48,657
  • 3
  • 76
  • 115
  • The original question was really broken, but I really appreciate the 2>/dev/null, which saved my bacon when I came back for it today – Webdev Tory Jun 08 '21 at 23:14