convert shell script into a binary executable


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting convert shell script into a binary executable
# 1  
Old 12-09-2010
convert shell script into a binary executable

Hello every one, i want to convert my shell script into a binary executable a .exe file , is it possible to do that if so are there any tools . Would the script take off when the arguments are parsed.

Thanks
Venu
# 2  
Old 12-09-2010
There is a shell compiler maintained and available here:

Francisco Rosales, home page
# 3  
Old 12-10-2010
Am I being thick?

Well, this is something I have often pondered. A way to write code that is far more difficult to decipher - unless you have the source.

We have a number of intelligent users (if that's not an oxymoron) who like to read scripts and work out what they do and how. Of course, there are various sensitive things that we want to keep secret from them, yet give them the scripted ability to do. Nothing too complex, but it often involves privileged access to a database, for which we store the passwords in a file. Of course, if you can read the script, you know where to find the file! Smilie

I grabbed at this link delighted that someone could solve all my woes, but I fail to get it to build. I have a few versions of AIX and two HPUX servers. From the README, it seems to suggest I just run a make, but that fails and I don't know even what it is trying to do. I've pretty much written everything as SQL or KSH (unless you count REXX on VM), so I've no experience in this. I did gcc compile the shc.c and get an executeable which I could then use to process test.ksh to create test.ksh.x, but this wouldn't run. Just the message "Killed" came back.

Am I being a complete fool? Smilie

Any pointers?

"Hat's Off" to Jim for finding this if it works. Smilie
# 4  
Old 12-10-2010
ksh93 comes with a compiler called shcomp
Code:
$ cat test
#!/bin/ksh
for (( i=1; i<=5; i++)); do
  echo Hello World
done
$ ( echo '#!/bin/ksh' ; shcomp test ) > test.bin && chmod +x test.bin
$ ./test.bin
Hello World
Hello World
Hello World
Hello World
Hello World

Which will not make it totally unreadable, but to a certain extent.
Code:
$ od -c < test.bin
0000000   #   !   /   b   i   n   /   k   s   h  \n  \v 023  \b  \0 003
0000020  \0 003  \f 002 005       i   =   1 001  \0 005  \f 002 004   i
0000040   +   + 001  \0  \f 002 006       i   <   =   5 001  \0 203  \0
0000060   @  \0 003 005   e   c   h   o 006   H   e   l   l   o 006   W
0000100   o   r   l   d  \0 003
0000106

# 5  
Old 12-10-2010
shcomp doesn't really compile the script, but saves the parser tree that's generated internally. The script itself is still traceable using -x as if it were plain text.

shc, as suggested, will encrypt the script using RC4, but you'll lose the cross-platform advantage. Also, somehow it seems to dislike newer versions of Linux, or at least VirtualBox, as the compiled scripts always died.
This User Gave Thanks to pludi For This Post:
# 6  
Old 12-21-2010
So, are there any suggestion how to get shc running? As a non-C person, I don't understand the compile process to get the tool installed, so I don't know what I'm looking for to fix it. Smilie



Robin
Liverpool/Blackburn
UK

Last edited by rbatte1; 12-21-2010 at 08:23 AM.. Reason: Grammer
# 7  
Old 12-21-2010
Are you on AIX 64 bit, as it looks like someone had a similar problem here and found a fix.

You could also try the -T option to shc, this also got it working of AIX 5.3 64bit for me, also fixed `PTRACE_ATTACH' undeclared error when generating on cygwin:

Code:
$ ./shc -T -f test.ksh
 
$ ./test.ksh.x test params 1 2 3
+ alias whence=type -a
+ alias ll=ls -l
+ alias la=ls -A
+ alias l=ls -CF
+ echo $@ is test params 1 2 3
$@ is test params 1 2 3
+ echo command line: ./test.ksh.x test params 1 2 3
command line: ./test.ksh.x test params 1 2 3
+ echo hello world
hello world
+ echo [581760] PAUSED... Hit return!
[581760] PAUSED... Hit return!
+ read DUMMY
done
+ exit 0

'
BTW I think you probably need to set CC=gcc before trying the make (If not I might be able to help if you supply the error make is giving):

Code:
$ CC=gcc ; export CC
$ make

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. AIX

executable problems with shell script in IBM servers

We have a java stand alone application running currently on sun Solaris system. The java application runs on Jdk 1.4. We are reshooting this java application to new Ibm servers. There are 10 unix scripts for this application. All scripts works well except one shell script, This shell... (2 Replies)
Discussion started by: poojagupta
2 Replies

2. Shell Programming and Scripting

Want to convert an expect script to binary in Linux

Does anyone know how to convert an expect script to binary in linux?. (3 Replies)
Discussion started by: John Wilson
3 Replies

3. Shell Programming and Scripting

Issue while executing C executable with argument in shell script

Hi All, I am new to this forum and also shell script :) My task is I have to read CSV file get the data from the file and use the data to call c executable with data as argument.And the output from c executable should be stored to new CSV file Please find below my code testfunction() {... (14 Replies)
Discussion started by: ravjot28
14 Replies

4. Shell Programming and Scripting

Convert binary file to csv and then back to the binary format

Hello *nix specialists, Im working for a non profit organisation in Germany to transport DSL over WLAN to people in areas without no DSL. We are using Linksys WRT 54 router with DD-WRT firmware There are at the moment over 180 router running but we have to change some settings next time. So my... (7 Replies)
Discussion started by: digidax
7 Replies

5. Shell Programming and Scripting

Convert binary to text Perl script

Hello everyone, I have a binary file with a structure unknown. I have found 2 perl scripts that it seems to do the convertion but I get sintactic errors when I run them, may somebody test these 2 scripts please and see if really work? One if from here... (10 Replies)
Discussion started by: Ophiuchus
10 Replies

6. UNIX for Dummies Questions & Answers

Missing print binary/executable

Hi friends, I am trying to execute some of our scripts and apparently I had this error message: bash: print: command not found Every other scripts runs smoothly excepts this that uses the print command. I search the /bin and it was not there. I also tried to search in the whole folder... (5 Replies)
Discussion started by: kokoro
5 Replies

7. Shell Programming and Scripting

Is there any script which convert binary file to CSV format

Dear guys; I have a binary file and I need to convert its data to csv format ...appreciating your help. Best Regards (14 Replies)
Discussion started by: ahmad.diab
14 Replies

8. Shell Programming and Scripting

can UNIX scripting be converted into binary(executable)

hi i wanna ask that can UNIX scripts be converted into exe files?? if so, how?? and can these scripts be implemented using c++ and using their executable... ---------- Post updated at 02:33 PM ---------- Previous update was at 10:53 AM ---------- plz anybody reply.... and ya i want to... (5 Replies)
Discussion started by: umarbangash
5 Replies

9. UNIX for Dummies Questions & Answers

running command prompt executable file in shell script

hi i have file extentioned with test.vbs. i am able to run this file n execute through command promt but i dont know how to run in shell script example: file name is test.vbs which contains strSoundFile = "C:\windows\Media\Notify.wav" Set objShell = CreateObject("Wscript.Shell") strCommand... (5 Replies)
Discussion started by: atl@mav
5 Replies

10. UNIX and Linux Applications

Linking Libaries to binary executable

Hello, I am using Open Suse 10.3. I have implemented Zeroconf and the program is working with out any errors. Libray linking for normal executable: gcc -o name name.c -lavahi-client.so (WORKING) Now i have to create a binary executable, to have the program running on a device. For a... (0 Replies)
Discussion started by: bhavana
0 Replies
Login or Register to Ask a Question