Is there way to convert a ruby script to executable file under Linux?
rubyscript2exe can do it, but it won’t encrypt the script, and will show
the content of the script under home directory when run, but I hope my
script protected.
Is there way to convert a ruby script to executable file under Linux?
rubyscript2exe can do it, but it won’t encrypt the script, and will show
the content of the script under home directory when run, but I hope my
script protected.
On Sat, Oct 19, 2013 at 12:18 AM, Previn L. [email protected]
wrote:
Is there way to convert a ruby script to executable file under Linux?
rubyscript2exe can do it, but it won’t encrypt the script, and will show
the content of the script under home directory when run, but I hope my
script protected.
See a recent discussion of the topic. You’ll find it here:
http://www.ruby-forum.com/.
Cheers
robert
Hi,
mruby [1] let’s you precompile scripts to bytecode which can be executed
later. However, it doesn’t very much in functionality above what the
specification demands, so if you’re heavily reliant on gems / extensions
you might have to implement that functionality yourself.
Jonas
Robert K. wrote in post #1124904:
On Sat, Oct 19, 2013 at 12:18 AM, Previn L. [email protected]
wrote:Is there way to convert a ruby script to executable file under Linux?
rubyscript2exe can do it, but it won’t encrypt the script, and will show
the content of the script under home directory when run, but I hope my
script protected.See a recent discussion of the topic. You’ll find it here:
http://www.ruby-forum.com/.Cheers
robert
I search the forum before issue my post, but seems didn’t find my want.
In Perl, there is par,
In Python, there is Pyinstaller
In Ruby, is there similiar function tool?
Previn L. wrote in post #1124954:
Robert K. wrote in post #1124904:
On Sat, Oct 19, 2013 at 12:18 AM, Previn L. [email protected]
wrote:Is there way to convert a ruby script to executable file under Linux?
rubyscript2exe can do it, but it won’t encrypt the script, and will show
the content of the script under home directory when run, but I hope my
script protected.See a recent discussion of the topic. You’ll find it here:
http://www.ruby-forum.com/.Cheers
robert
I search the forum before issue my post, but seems didn’t find my want.
In Perl, there is par,
In Python, there is Pyinstaller
In Ruby, is there similiar function tool?
I think the thread he was referring to might be this one:
https://www.ruby-forum.com/topic/4417472
As for mruby, there’s always the possibility of writing a simple C file
that has the compiled ruby scripts embedded in it and statically links
to mruby, then you would have one independent ELF file.
Jonas
Jonas Kulla wrote in post #1124933:
Hi,
mruby [1] let’s you precompile scripts to bytecode which can be executed
later. However, it doesn’t very much in functionality above what the
specification demands, so if you’re heavily reliant on gems / extensions
you might have to implement that functionality yourself.Jonas
Thanks, Jonas, I haven’t tested it yet, but seems still notI want, I
hope get a executable ELF file that can be run without Ruby/or mRuby any
more, so it can be distributed to other machines directly.
I think the thread he was referring to might be this one:
Gem for basic code protecction? - Ruby - Ruby-ForumAs for mruby, there’s always the possibility of writing a simple C file
that has the compiled ruby scripts embedded in it and statically links
to mruby, then you would have one independent ELF file.Jonas
Thanks, Jonas
I read the post 4417472, seems rubyencoder is a solution, but two issues
with it (1) it’s not free (2) It depends on glibc version, under RHEL4,
it need glibc2.4, it’s so painful to install glibc2.4 under RHEL4, I
didn’t get success so far
About mruby, would you kindly share a smaple C file that has compiled
ruby scripts embedded in it? I’m sorry I’m not familiar with C program.
Many thanks,
Previn
Hi Jonas,
Thanks for the reference script and flow shared, I get the ELF
succesfully.
But still some issues with this flow.
<1> Seems mruby can only compiled on RHEL6, I got failure on both
RHEL4/5
<2> Seems some regular command not supported in mruby, such as “exit,
require”, I’m not sure my usage issue, or it’s really this way
Thanks,
Previn
Previn L. wrote in post #1125141:
About mruby, would you kindly share a smaple C file that has compiled
ruby scripts embedded in it? I’m sorry I’m not familiar with C program.
The C program in its most basic form would be something simple like
this:
#include “mruby.h”
#include “compScript.h”
int main(int argc, char *argv[])
{
mrb_state *mrb = mrb_open();
mrb_load_irep(mrb, myCompiledScript);
mrb_close(mrb);
}
You will have to compile your script(s) using the mrbc command line
tool, like so:
mruby/bin/mrbc myScript.rb -o compScript.h -B myCompiledScript
This will produce a header file which we’re directly including in
main.c.
Please remember however that mruby is experimental code that hasn’t even
seen an alpha release yet, so if you’re going to use it, make sure to
thoroughly test your results.
Previn L. wrote in post #1125276:
<1> Seems mruby can only compiled on RHEL6, I got failure on both
RHEL4/5
That’s weird, mruby is completely written in ANSI C so it should run
pretty much anywhere. Maybe you compiled it on a too new glibc version?
In that case you should just compile it on an older system.
<2> Seems some regular command not supported in mruby, such as “exit,
require”, I’m not sure my usage issue, or it’s really this way
In the core only commands from the ruby specification are implemented.
For require, you can just compile all scripts together if they depend on
each other. Remember mruby is a completely new implementation and it
won’t be compatible with any existing MRI gems/bindings.
For ‘exit’ I think there actually exists a gem. Look in the “mrbgems”
folder, and edit the “default.gembox” file with a line like this:
conf.gem :core => “mruby-exit”
Jonas
Hi Jonas,
========================================================
The error when compile mruby:
…
ruby ./minirake
(in /rh/server/mruby_test/rhel5/mruby-mruby-9eadd05)
CC tools/mrbc/mrbc.c -> build/host/tools/mrbc/mrbc.o
CC src/compar.c -> build/host/src/compar.o
CC src/backtrace.c -> build/host/src/backtrace.o
…
CC build/host/mrbgems/mruby-sprintf/gem_init.c ->
build/host/mrbgems/mruby-sprintf/gem_init.o
CC mrbgems/mruby-print/src/print.c ->
build/host/mrbgems/mruby-print/src/print.o
MRBC mrbgems/mruby-print/mrblib/print.rb
CC build/host/mrbgems/mruby-print/gem_init.c ->
build/host/mrbgems/mruby-print/gem_init.o
CC mrbgems/mruby-math/src/math.c ->
build/host/mrbgems/mruby-math/src/math.o
rake aborted!
Command Failed: [“gcc” -g -O3 -Wall
-Werror-implicit-function-declaration
-I"/rh/server/mruby_test/rhel5/mruby-mruby-9eadd05/include"
-I"/rh/server/mruby_test/rhel5/mruby-mruby-9eadd05/mrbgems/mruby-sprintf/include"
-I"/rh/server/mruby_test/rhel5/mruby-mruby-9eadd05/mrbgems/mruby-print/include"
-I"/rh/server/mruby_test/rhel5/mruby-mruby-9eadd05/mrbgems/mruby-math/include"
-MMD -o
“/rh/server/mruby_test/rhel5/mruby-mruby-9eadd05/build/host/mrbgems/mruby-math/src/math.o”
-c
“/rh/server/mruby_test/rhel5/mruby-mruby-9eadd05/mrbgems/mruby-math/src/math.c”]
<1> I just skip ‘require’ first
<2> Thanks for your solution, that really make command ‘exit’ works.
<3> Now it report: ` not implemented, is there solution for this issue?
cat t.rb
#!/usr/bin/env ruby
c_os = uname -s
mruby-mruby-9eadd05/bin/mrbc t.rb
mruby-mruby-9eadd05/bin/mruby -b t.mrb
trace:
NotImplementedError: ` not implemented
Thanks,
Previn
Dear Jonas,
Thanks for your guide, seems use mruby to do this is still difficult,
expecting it will be implemented in feture ruby release.
Thanks again,
Previn
Sorry for the delay.
My bad, I misunderstood, I thought you got errors running a compiled ELF
on earlier RHEL versions. From the error messages you’re getting it
seems like the math gem is using functions that might be different (?)
or not present in earlier glibc versions. I can’t really help you here
as I don’t have the means to test on such old RHEL versions. You can
either disable the math gem in “default.gembox” or investigate the
compile error yourself.
c_os =
uname -s
I don’t think mruby has this syntax to execute sub processes
implemented. You can check out the Ruby Specification [1] for a list of
things that mruby ought to support.
Jonas
[1]
http://www.ipa.go.jp/osc/english/ruby/ruby_draft_specification_agreement.html
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs