Want to convert to exe file

Hello Gurus,

I have written one shell script will check the database healths.
Now I want to convert the ksh script to a executable one so that I can install it as a software like windows to any unix systems.

How I will achieve this?

Thanks-
p

The shell script file itself is an executable file
You can transfer the file to any Unix machine.
If you have config files or any other files used in the script, copy those files as well
If you have large number of files, tar them

Hi ,

Thanks for your reply.
I wanted to know how can I convert the .ksh shell script to a exe binary file so that no one can see the inside details.

Thanks-
P

You add .command as suffix.it worked on mac osX

your script.command
1 Like

Not able to understand...

For example :

My script name is dbhealth.ksh

now as per your update I need to add .command

like ~ dbhealth.ksh.command

Is it correct?

Thanks-
p

No try to replace .ksh by .command

There is a compiler for shell scripts called shc , but compiling will make your script less likely to run on other platforms than the one you compiled on.

You can obfuscate the script all you want, but to run the script on a machine, it must decrypt on the machine, so that doesn't actually get you anything.

You may have to write it directly in C and then write an installation script that you can deliver it with. The script would (probably) extract & decrypt your source C, compile it and then remove the source code.

Not a great plan, because I can hardly write in C myself, so it's no easy task. You might be able to script a similar logic using shc, but it might be tricky to ensure it will work for every server you might want to deliver it to.

..... and like Corona688 says, it's only obscuring it. There will always be a way to reverse engineer it if the end user is determined enough. It might be enough to deter a casual curious customer though.

Robin

Hi.

There is a built-in compiler with ksh (93):

SHCOMP(1)                 User Environment Utilities                 SHCOMP(1)

NAME
       shcomp - compile a ksh93 shell script

SYNOPSIS
       shcomp [ options ] [infile] [outfile]]

...

EXAMPLE
       ( echo '#! /bin/ksh93' ; shcomp myscript ) > myscript.bin &&
       chmod 755 myscript.bin
       ./myscript.bin

-- excerpt from man shcomp.

That seems to be easy to try. Whether it is good for the OP requirements is hard to say.

Best wishes ... cheers, drl

1 Like

I'm not sure that shcomp is in ksh93. I think it is a separate executable and not always supplied by default. I have AIX 6.1.8 which doesn't have it and RHEL 6.5 which doesn't even list it if I yum whatprovides */shcomp I did, however, get zsh offered on a wider search but that seems to be a different shell altogether.

I did find a hit here for source code, but not being a C programmer, I have no idea how to compile it other than:-

gcc -o shcomp shcomp.c

..... which gave a load of errors that I don't understand at all.

I've used shc but struggled with the limited portability of the object. Perhaps shcomp is an alternative with more portability, even if there is reduced obscurity. Can anyone suggest where we can get it to do some testing?

Robin

There is another thread about this:

shcomp does not really obfuscate the contents...

Hi.

Thanks for the correction; it is part of the ksh93 distribution, but not a builtin.

There is a tar file of ksh93 at Debian -- Details of package ksh in bookworm , however I didn't try to comple it, I just looked it over. There is a tar file of Debian patches, some of which seem to relate to shcomp, but I just skimmed it, noting that file rules is a makefile that seems to make ksh93, including shcomp for the Debian environment.

As Scrutinizer noted in the other thread, there is not much obfuscation, but the topic of encryption of shell scripts has been talked about extensively, with the consensus that encryption is not viable because one needs the key to decrypt the encrypted source. Perhaps with shcomp some obfuscation is enough.

I did find a shell-to-perl converter, which can obscure the source for the non-perl-savvy, but that seems to be getting far afield.

There is a reference to ccsh at Compile ksh scripts into binaries - Toolbox for IT Groups to C++ Compilers From Comeau Computing Targeting ANSI/ISO C++ Standard / C and C++ Compiler for Multi-platform Needs , but I could not tell if they were still in business.

Best wishes ... cheers, drl

1 Like