Deploy bash script with ruby gem

I was trying to deploy a shell-script (in bash) along with a gem.
rubygem
creates a wrapper and tries to execute it as a ruby program.

Searching brought me to the “exec” method (stackoverflow). I tried
wrapping the script in a string using %q but this gave errors (I suppose
since this is a bash script, “exec” uses /bin/sh).

Kernel.exec %q{

… several lines of bash
}

I then tried to force exec to use “bash” but this just prints out the
whole string and says “file name too long”. I guess it takes the string
as a file name.

Kernel.exec ‘/bin/bash’, %q{

… several lines of bash
}

What am I doing wrong? Is there a cleaner way of deploying a script
along with a rubygem ?

R. Kumar wrote in post #1153828:

I was trying to deploy a shell-script (in bash) along with a gem.
rubygem

What am I doing wrong?

put the string in a file and execute it:

File.write("/tmp/a.sh",script_string)

need a chmod ?

system("/bin.bash","-c","/tmp/a.sh")

Is there a cleaner way of deploying a script
along with a rubygem ?

bashgem :slight_smile:

Regis d’Aubarede wrote in post #1153837:

bashgem :slight_smile:
Thanks.

This is the only link I can find for bashgem. Doesn’t say anything and
its quite confusing going through the source tree to figure out.

Do you mean this ? I can’t find a gem by that name in rubygems.org.

R. Kumar wrote in post #1153839:

Regis d’Aubarede wrote in post #1153837:

bashgem :slight_smile:
Thanks.

Do you mean this ? I can’t find a gem by that name in rubygems.org.

sorry, it’s was a joke !

if rubygems is for ruby , bashgem can be for bash… do it yourself :slight_smile: