Compilation


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Compilation
# 8  
Old 10-05-2010
Hi All,

Thanks for the reply.

Methyl-> thanks for your suggestion.

I just raised this question out of curoisity and felt few times compilation might have hepled me.
# 9  
Old 10-05-2010
Compile shell script?

In answer to that question, there is no DIRECT way to compile a shell script. There ARE ways to PACKAGE a shell script, but to truly COMPILE a shell script? None that I know of.

My own methods start with: "first translate the shell script into C, FORTRAN, ADA, or Pascal, then...".

The entire reason for using a shell script instead of assembler, C, Pascal, etc is that it is easy and natural to call utilities, pipe processes, and replicate the commands you would use to perform the same functions manually from the command-line. If you need a compiled program, then you really need to translate the process into something that is somewhat self-sufficient and does not require those external utilities, the shell, or anything but the resources of the executable environment.

Pick a language, but not at random. Examine what your script does, and consider the available compilers in terms of which language implementation answers you need in the most elegant, natural fashion. Design your project with the script functions and this language in mind. When it looks complete (a peer overview may be useful at this point) you can decide on some coding standards and get to the fun part: coding.

You will find the process somewhat slower and more complex, but potentially far more rewarding, compared to scripting.

I would almost bet, however, that compiling is terrible overkill and an inefficient use of resources in answer to your real need.
Can you elaborate a bit on the situation that prompted your question?

Last edited by wpeckham; 10-05-2010 at 02:30 PM..
# 10  
Old 10-05-2010
@wpeckham
You are right. Most of the unix Shell Script compilers generate "C" language code, then compile.
# 11  
Old 10-05-2010
Hi wpeckham,

Thanks for the explanation. As I said , I asked this just out of curiosity. I found that there is an utility called "shc" which can be used to compile the shell scripts.

The reason for doing the compilation is , so many users will use the same application account to login to the box and If we feel to protect our scripts being inspected/modified by some one else. I know that we can handle this by changing file permissions how ever this I can do only if the user accounts are different. As i stated since all users are using same applicationa account and we dont have any individual accounts to login to the box.So,I just thought it might be a worth to keep only the compiled copies in the directory needed.

Appreciate all for your valuable thoughts on this.

Regards
Ravi Sastry P
# 12  
Old 10-06-2010
Quote:
Originally Posted by panyam
The reason for doing the compilation is , so many users will use the same application account to login to the box and If we feel to protect our scripts being inspected/modified by some one else. I know that we can handle this by changing file permissions how ever this I can do only if the user accounts are different.
So make a new account -- that's what they're there for. Grant read-write permissions to the new user, execute-only permissions to the application group, and nothing else at all to anything. Application users will still be able to run the script under the 'application' user without being able to read or modify it, and people with proper clearance can login to the new account to modify it.

Compiling a script is fundamentally dodgy anyway. I wouldn't trust a compiled script to do exactly what the shell script did for anything but rudimentary scripts, and if it starts messing up how in the world are you going to figure it out? Proper permissions properly is much better than compiling it, that just obfuscates the file in the hope nobody's clever enough to run 'strings' on it.

Last edited by Corona688; 10-06-2010 at 04:19 PM..
This User Gave Thanks to Corona688 For This Post:
# 13  
Old 10-06-2010
Hi Corona,

Thanks for the suggestion.

Cheers
Ravi
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. AIX

VIM compilation

Hi, I tried to compile vim on AIX OS. I tried all version from 6.4 to 7.2 and the effect is the same. ./configuration --prefix=/home/me OK make The make try to compile first file buffer.c ane it gived me message like this gcc -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_ATHENA ... (2 Replies)
Discussion started by: marcintom.aviva
2 Replies

2. AIX

Problem in compilation.

Hi, I am executing the below mentioned code:- proc SQLCHECK=SEMANTICS iname=CDBInteractor.pc parse=none code=cpp cpp_suffix=cpp g++ -c main.cpp g++ -o pre_request_engine main.o -I/oracle/oracle/app/product/10g/precomp -L/oracle/oracle/app/product/10g/lib32 -lnsl -ldl And... (2 Replies)
Discussion started by: tushar_tus
2 Replies

3. Programming

C Compilation problem

Dear all I am new to C programming In response to the post cat get_time.c #include <stdlib.h> #include <sys/time.h> main() { struct timeval tv; struct timezone tz; struct tm *tm; gettimeofday(&tv, &tz); tm=localtime(&tv.tv_sec); printf("... (2 Replies)
Discussion started by: on9west
2 Replies

4. UNIX for Dummies Questions & Answers

Compilation

Hi All, We have a C program existing in one of the folders which I have to modify a lil bit, When I'm trying to compile the program using GCC or CC command its showing as ksh: gcc: not found is that mean there is no compiler or do I have to verify for something, please advice Thank... (2 Replies)
Discussion started by: diggermf
2 Replies

5. Linux

c++ compilation error

Hello every one, here i am attempting to compile a c++ module using gcc.it is throwing a error . error: ==== > make -S dummyCHARGP /usr/local/bin/gcc -g -DDEBUG -DMAT -I. -I/swtemp/usbs/cc/unix-ce/root/subsys/lib/Linux/ -I/opt/dce/include -I/opt/dce/include/dce ... (12 Replies)
Discussion started by: mannam srinivas
12 Replies

6. Programming

c compilation process

What is symbol table? (1 Reply)
Discussion started by: rangaswamy
1 Replies

7. Programming

compilation problem

i have a class name 1.c in tht i am using function n wich has his body in 2.c and declaration in 2.h now how can i compile 1.c. ex; 1.c int main() { //some data n(10); //somedata } ***** 2.c int n(int k) { //some data } int main() { some data (2 Replies)
Discussion started by: phani_sree
2 Replies

8. Programming

Compilation error

I am compiling a software xchm on solaris 10. First i run './configure' There is no error. But when i start compiling using 'gmake' following error shown /usr/local/include/wx-2.6/wx/x11/brush.h: In copy constructor `wxBrush::wxBrush(const wxBrush&)':... (3 Replies)
Discussion started by: mansoorulhaq
3 Replies

9. Solaris

compilation problem

I am compiling a software named wine When i run make then at the end following error generated. DVAPI32_ -foversion.res version.rc ld.so.1: ../../tools/wrc/wrc: fatal: relocation error: file ../../tools/wrc/wrc: symbol wine_casemap_upper: referenced symbol not found *** Signal 9 make:... (0 Replies)
Discussion started by: mansoorulhaq
0 Replies

10. UNIX for Dummies Questions & Answers

Kernel compilation

I have re-compiled kernel source code available in /usr/src/linux.2.4.20 with "make" command. The compilation is succesful. Now the problem is create the image for this. The documentation in the same folder says that now you have compile "make image". There is no option for image in Makefile. ... (3 Replies)
Discussion started by: mankrish
3 Replies
Login or Register to Ask a Question