can't invoke an executable and plug to its output stream - racket

I want to invoke mvn command from within racket code, and then stay tuned to the process and get back the output of maven as it works, present it to the user line by line.
I have tried to implement it using a batch file that navigates to my maven project and invoke the mvn command (currently simple mvn clean will satisfy..)
cd\
cd projects\java\projA
mvn clean
I have tried to invoked this batch file using either system and process, but both returns me the same result: mvn is not recognized. (off course it is, as I can invoke this batch file on my own and it works perfectly).
(define invocation-method (lambda () (system "c:\\test.bat")))
;; capture output
(string-split (with-output-to-string invocation-method) "\n")
and the output:
'mvn' is not recognized as an internal or external command,
operable program or batch file.
'("\r"
"C:\\Users\\aviad>cd\\\r"
"\r"
"C:\\>cd projects\\java\\projA\r"
"\r"
"C:\\projects\\java\\projA>mvn clean \r")
it seems that when I invoke it from racket context it is not familiar with the path variable or something (and perhaps even other environment variables ?).
any idea?

Related

Execute jar and display text in jenkins console log

I have abc.jar file to deploy and run in remote machine.
I have transferred the file using jenkins, now what I have done is, call a a.bat batch file on remote machine using psexec in Execute Windows Batch Command.
a.bat executes the abc.jar
When the jar begins execution, the command prompt texts are stored in a file.
using java -jar abc.jar >> a.log 2>&1
Now what I want is to display the a.log contents in the jenkins console when the jar file is being executed
(the file is continuously being written and I want to show it in jenkins console as it is being written)
I have tried to do it using parallel processing by calling start twice, one for calling batch file, another using type for displaying.
But when I use start I get Process leaked file descriptor .
Is there any other way I can achieve this. Be it calling powershell or scheduled task in jenkins.
You need to look for tee equivalents in windows , there are few like GNU utilities for Win32, however if you have cygwin you can still use tee which will easy the prcoess.
Now the wuestion arises how to run my jar file on cygwin from jenkins ?
you can still use execute windows[batch] shell. and add cygwin installation path to the PATH variable and start using linux command like a BOSS.
or you can use powershell tee in built command from batch.

Command-line input with Sys.stdin() not working in Haxe

I'm trying to use the input function from the Sys class, but when I run the build and the prompt occurs, I'm unable to enter any input. What alternatives are there to Sys, or what ought I do to resolve this? I've checked Haxelib and haven't found anything that I think can be used.
For reference, what I have written:
Sys.println("First player's name: ");
var p1:String = Sys.stdin().readLine();
My hxml args:
-main Main.hx
-cp src
-cp src/cards
-cp src/cards/library
-lib Random
-neko test.n
-cmd neko test.n
It works fine if you manually start the generated test.n instead of doing that via -cmd in the hxml. I suspect that the Haxe process does not direct input to the stdin of the -cmd process or something like that.
If you still want to compile and run at the same time, I recommend creating a little .bat (or .sh if you're on Linux) script for this:
haxe build.hxml
neko test.n

How to specify make program in emacs?

Vim has makeprg variable. This variable takes program name which will be executed if :make is entered. Is there something similar in emacs?
Thanks.
The variable compile-command specifies the compiler program, which you can customize as needed. Here's the manual page for M-x compile and family.
I'm not aware of a make command in Emacs, but there is compile:
Compile the program including the current buffer. Default: run `make'.
Runs COMMAND, a shell command, in a separate process asynchronously
with output going to the buffer `*compilation*'.
The command that gets run by compile is defined by the variable compile-command, which can be set like this:
(setq compile-command "some command")
compile-command's default value is "make -k ".

Define default compile command in Emacs

I have a project that uses a bash script to invoke cmake and make. I have successfully used this script from Emacs by using M-x compile, followed by typing:
cd ../..; ./build.sh
in the minibuffer. (The project organization is top/src/various_source_folders and build.sh is in top/.)
I am trying to define a directory variable to specify the default command to use for compile. I have tried the following (both with single or double quotes around the compile command) in .dir-locals.el:
((c++-mode
(compile-command 'cd ../..\; ./build.sh')))
Which gives no errors, but M-x compile still defaults to make -k.
((c++-mode
(set-variable 'compile-command' "cd ../../\; ./build.sh")))
Which gives a warning about unsafe variables. Even if I choose apply, compile still defaults to make -k
Simply using M-x eval-buffer with the second line ((set variable...) in *scratch* correctly sets the compile command.
Is there a different way I can/should be doing this?
Found an answer here.
Two periods and some parenthesis were missing from the syntax:
((c++-mode
. ((compile-command . "cd ../../\; ./build.sh"))))

lisp as a shebang script vs lisp running in SLIME

I just started with common-lisp, having come from C++ and Python. I'm trying to run a simple SDL program that does nothing other than show an image on-screen. I can get it working from within SLIME. The problem is, it won't work when run from the shell as a script.
My program looks like this:
#!/usr/bin/sbcl --script
(asdf:operate 'asdf:load-op :lispbuilder-sdl)
(defun main ()
(sdl:with-init ()
(sdl:window 320 240)
(sdl:draw-surface (sdl:load-image "image.png"))
(sdl:update-display)
(sdl:with-events ()
(:quit-event () t)
(:video-expose-event () (sdl:update-display)))))
(main)
When I run this as a script, I get the following error:
mkg#chisel:~/projects/common-lisp/sandbox$ ./hello-world.lisp
unhandled ASDF:MISSING-COMPONENT in thread #<SB-THREAD:THREAD "initial thread" RUNNING {AA5E849}>:
component "lispbuilder-sdl" not found
0: (SB-DEBUG::MAP-BACKTRACE #<CLOSURE (LAMBDA #) {AAF1EF5}>)[:EXTERNAL]
(... long backtrace omitted)
Oddly, this program works fine if I do the following. I open the program in Emacs, start SLIME in another window, and in the SLIME window, I enter the first line of the program:
(asdf:operate 'asdf:load-op :lispbuilder-sdl)
Then, in the editor window, I hit C-c C-k (compile/load file). This pops up a window showing image.png, as expected.
Why does this not work when run as a shebang script? How can I fix it?
As the man page for sbcl says, --script implies --no-sysinit --no-userinit --disable-debugger --end-toplevel-options, which means that initialization files are not read, and so if you set up ASDF registry there it is not set up, and so it cannot find the lispbuilder-sdl system. You need to either set up the registry in the script itself, or save an executable core with the registry already set up and call that instead of the default sbcl. Usually you can also save libraries in the core instead of loading them in the script, but I am not quite sure how that interacts with non-Lisp libraries and resources.
The usual way when developing in lisp is to use ASDF to describe project and its dependencies. Then, you can easily (asdf:oos 'asdf:load-op :yourapp).
For most implementations there is a way to generate executable form asdf definition.