On Mon, Apr 30, 2012 at 11:20 PM, ольга крыжановская
<olga.kryzhanov...@gmail.com> wrote:
> On Wed, Apr 25, 2012 at 12:26 PM, Dan Shelton
> <dan.f.shel...@googlemail.com> wrote:
>> Hello, I have problems with Suse and compiled shell scripts. If I try
>> to execute a shell script compiled with shcomp on Solaris Express it
>> works like a charm but on Suse the system refuses to execute the
>> binary:
>> lorddan@test:~> cat x.sh
>> print "hello world"
>> print --version
>> lorddan@test:~> shcomp x.sh x
>> lorddan@test:~>
>> -bash: ./x: cannot execute binary file
>>
>> Does anyone have a tip why this fails?

> Dan, have a look at
> https://wiki.archlinux.org/index.php/Binfmt_misc_for_Java IMO the same
> could be used to recognise compiled shell code and use /usr/bin/ksh as
> interpreter.
> We only have to figure out how to use binfmt.

On Linux you can do this:
-- snip --
echo ':shbinexec:M::\x0b\x13\x08:\xff\xff\xff:/usr/bin/ksh93:O' >
/proc/sys/fs/binfmt_misc/register
-- snip --
After this point all compiled shell scripts (even those with only the
exec bit but not the read bit set) can be executed directly.

For example:
-- snip --
# as user "root":
# echo ':shbinexec:M::\x0b\x13\x08:\xff\xff\xff:/usr/bin/ksh93:O' >
/proc/sys/fs/binfmt_misc/register
# as plain user:
$ printf 'printf "argv=%%d\\n" $#\nprintf "argv=%%q\\n" "$@"\n' |
shcomp /dev/stdin args.shbin
$ args.shbin "hello world" "foo bar"
argv=2
argv='hello world'
argv='foo bar'
-- snip --

AFAIK the only "missing step" is to teach systemd to do this at system
startup...

----

Bye,
Roland

-- 
  __ .  . __
 (o.\ \/ /.o) roland.ma...@nrubsig.org
  \__\/\/__/  MPEG specialist, C&&JAVA&&Sun&&Unix programmer
  /O /==\ O\  TEL +49 641 3992797
 (;O/ \/ \O;)

_______________________________________________
ast-users mailing list
ast-users@research.att.com
https://mailman.research.att.com/mailman/listinfo/ast-users

Reply via email to