This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-10-23
Channels
- # aws-lambda (1)
- # bangalore-clj (3)
- # beginners (80)
- # boot (8)
- # clojars (1)
- # clojure (200)
- # clojure-dev (37)
- # clojure-greece (26)
- # clojure-italy (11)
- # clojure-norway (3)
- # clojure-russia (14)
- # clojure-spec (21)
- # clojure-uk (30)
- # clojurescript (50)
- # core-logic (10)
- # core-matrix (1)
- # cursive (15)
- # data-science (21)
- # datomic (45)
- # devcards (2)
- # emacs (4)
- # fulcro (12)
- # garden (2)
- # jobs (5)
- # juxt (1)
- # lambdaisland (1)
- # leiningen (4)
- # luminus (20)
- # lumo (26)
- # off-topic (33)
- # onyx (27)
- # parinfer (1)
- # pedestal (3)
- # perun (5)
- # re-frame (20)
- # reagent (27)
- # ring (1)
- # ring-swagger (21)
- # shadow-cljs (259)
- # spacemacs (14)
- # yada (3)
this writes to a local file
/bin/cat <<EOM >$FILE
text1
text2
text3
text4
EOM
Is there a way to write directly to a remote-file (that I can access via ssh), WITHOUT 1. writing file locally and 2. scp-ing it over ?@qqq, of course. As a first approximation, cat | ssh remote.host tee out.file
@pesterhazy turns out my actual problem is slightly different from what I described (running multi line ssh commands), and I ended up finding ssh username@host <<EOF ... EOF (originally was write script on remote, then run it, but turns out running multi line remote cmds is possible)
right
unfortunately quoting is a huge hassle with ssh
unix at its worst
probably better in almost all circumstances to scp a shell script and then execute it
too bad https://scsh.net/ never took off
that's what ansible does for example
yeah I'm really intrigued by scsh
believe me I've thought about it many times
but it's too big of a project, and lumo is not fast enough
for a simple "println" - bash: 30ms, lumo: 250ms
it gets much slower if you add heavy macros like core.async
it's just not the right tool for building a shell unfortunately
remember that shells use subshells for lots of things, so it adds up
it's kind of incredible there's no unix tool to "write stdin to file"
there's tee, which writes to the file passed as an arg but also to stdout (so you need to redirect to /dev/null)
there's bash -c 'cat>"$0"'
but who can remember that??
@joelgluth right I buried the lede there. I'm thinking of contexts where a simple process call is needed (not a bash command). So for example, sudo echo aasdf > /etc/hosts
won't work
but echo asdf | sudo tee /etc/hosts
will, or echo asdf | sudo bash -c 'cat>"$0"' /etc/hosts
using bash as glue is not desirable in a lot of situations, especially because then you need to worry about quoting
Sounds like maybe you want process substitution. I just discovered it recently, and dang is it cool. http://wiki.bash-hackers.org/syntax/expansion/proc_subst
Also some useful info here: https://unix.stackexchange.com/questions/17107/process-substitution-and-pipe
If only cat
had a --out-file
option!
dd of=my.fil
would work I guess