Arc Forumnew | comments | leaders | submitlogin
How to run anarki as utility, not REPL?
3 points by caddr 2773 days ago | 6 comments
Hi! It's my first post here. I guess it's a best place to ask question on arc/anarki (if not to discuss a pull request on GitHub).

So, what I want to do is quite simple. 1) Say, I have some file with arc code "plot.arc".

2) I want to read data from another file "data.csv"

3) I expect to get result into the new file "result.svg"

How is best to do it in Windows (8)?

I would like to do something like that

c:\home\denis\sandbox>anarki plot.arc data.csv result.svg

So far, I haven't found a way how to do it, there is not so much info on arc issues through google search. However I think it's quite basic and should be possible somehow?

Regards, Denis

P.S. It's ok to add racket or anything to the command line above, just to make it work



4 points by jsgrahamus 2772 days ago | link

This works for me in anarki, which is the community edition of arc:

  steve@steve-Satellite-L555D:~/anarki$ cat test.arc
  (prn "hello, world!")
  (quit)

  steve@steve-Satellite-L555D:~/anarki$ ./arc.sh test.arc > test.out

  steve@steve-Satellite-L555D:~/anarki$ cat test.out
  hello, world!

  steve@steve-Satellite-L555D:~/anarki$ 
Not sure how to do pass an file name to arc itself.

-----

4 points by akkartik 2772 days ago | link

You're almost there. To pass in to Arc a filename argument to write to, you'd say this:

  $ cat test.arc
  (tofile (argv 1)
    (prn "hello, world!"))
(The quit is unnecessary since Arc will automatically quit after running all commands in batch mode.)

  $ ./arc.sh test.arc test.out
  $ cat test.out
  hello, world!
argv is a list containing commandline arguments, and tofile redirects prn to some given filename.

-----

4 points by caddr 2772 days ago | link

Thanks jsgrahamus and akkartik!

Your examples are valid in Linux, but I was trying to launch anarki in Windows. So I've made windows batch file arc.cmd following arc.sh. Seems it works now. I have made a pull req to the repo.

...Only thing - how to port rlwrap to windows? And what (for what) is it? Better REPL formatting? :-)

-----

3 points by akkartik 2772 days ago | link

Many thanks for your pull request! Support for Windows chronically lags behind Unix, and I'd love to hear about any more bugs you run into on Windows.

rlwrap is just a little program which provides some standard features of Unix shells like commandline history and keyboard shortcuts. It's nice to have but certainly not essential.

-----

3 points by zck 2769 days ago | link

Just echoing that rlwrap isn't needed. I actually added an arg (-n) to arc.sh that doesn't use rlwrap. I use it when running arc inside an emacs shell, because emacs has terminal integration that I prefer.

-----

3 points by jsgrahamus 2769 days ago | link

I started using ansi-term in emacs to launch a shell file which wrapped rlwrap around the file I wished to execute. Turns out that M-x no longer works in that buffer.

-----