LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-31-2003, 04:09 AM   #1
dawood shaheen
LQ Newbie
 
Registered: Jul 2003
Posts: 3

Rep: Reputation: 0
bash shell


hello everbody,
I am new to linux interface, i have made a script in linux using bash commands.
Now is there any way that i can convert the file in binary or any other format so that no one can modify/view the source code ?????????
 
Old 07-31-2003, 05:53 AM   #2
lfur
Member
 
Registered: Jul 2003
Location: Slovenia
Distribution: Slackware & FreeBSD
Posts: 209

Rep: Reputation: 30
First you have to add:
#!/bin/bash

at the top of the script, then change read, write executable attributes:
chmod 700 scriptname

will make ti readable, writable, executable only for you.

Enjoy
 
Old 07-31-2003, 07:11 AM   #3
dawood shaheen
LQ Newbie
 
Registered: Jul 2003
Posts: 3

Original Poster
Rep: Reputation: 0
dear Ifur
i dont even want the root user to open the source ???
Like we code in c++ (in linux) and then compile it with
g++.
Is there anything like that we can do to bash shell ????
 
Old 07-31-2003, 07:43 AM   #4
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
no real way AFAIK, maybe just compress it?

for example your working bash script is *myscript.sh*

to encrypt or hide it as what you wanted to do:

tar -czf myscript myscript.sh
rm myscript.sh
chmod 400 myscript

to run your script:

tar -xzf myscript -O | bash

its up to you if you want to replace tar to other utilities with a *key*
password to encrypt it.
 
Old 07-31-2003, 12:17 PM   #5
lfur
Member
 
Registered: Jul 2003
Location: Slovenia
Distribution: Slackware & FreeBSD
Posts: 209

Rep: Reputation: 30
dawood shaheen,

is it possible that you are reffering to the binary files? Which actually can be seen/printed but it prints out garbage. Well if you are, maybe this would help. Binary file is machine code, while *sh scripts are just sets of commands, that you could easily type directly in the console, and are used mostly to automate tasks.

Enjoy

Last edited by lfur; 07-31-2003 at 12:18 PM.
 
Old 07-31-2003, 03:16 PM   #6
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
lfur, he clearly knows what a bash script is as he's just written one, and also what binary code is as that what he's aluding too. he just wants the contents of it not to be available to it's users.
 
Old 07-31-2003, 05:15 PM   #7
lfur
Member
 
Registered: Jul 2003
Location: Slovenia
Distribution: Slackware & FreeBSD
Posts: 209

Rep: Reputation: 30
acid_kewpie,

I am completely aware of my post being somehow naive, but sometimes the most obvious thing is just not so obvious as it seems.
Just an example: there was a guy, whos vim was acting very weird. It wasn't recognizing commands and a bunch of other stuff. People wer suggesting him to have a look at his Xmodmap file and all sorts of things related to input devices and broken software. But the real problem was, that there was no .vimrc in his home dir - and he was no vim newbie.
This example surely isn't related to bash script problem, but the meaning of my post here is what I've already said: sometimes even the most obvious things just aren't as obvious as they seem.

No hard feelings!

Enjoy
 
Old 08-01-2003, 04:07 AM   #8
dawood shaheen
LQ Newbie
 
Registered: Jul 2003
Posts: 3

Original Poster
Rep: Reputation: 0
dear dear all,
i think i am not able to clear my problem,
lets see
i have written a shell programme which does specific jobs, Now i want to give / distribute this shell to other branches of my office, BUT i dont want them to see / alter my code BUT they should be able to run the file (shell).
What can i do now ???????
 
Old 08-01-2003, 04:40 AM   #9
slakmagik
Senior Member
 
Registered: Feb 2003
Distribution: Slackware
Posts: 4,113

Rep: Reputation: Disabled
I think I know what you're talking about. On an old DOS box I've got a program called bat2exec which takes a batch file and compiles it into a .com file which makes it very difficult to reproduce or modify. (The actual purpose is just to speed execution of large batch files.) A compiler for scripts just like gcc compiles C. I don't know if there's anything like a 'bash2bin' kind of function or utility for Linux but am I least understanding what you want? I mean, it's not encrypted or anything or password protected or whatever, but they still wouldn't be able to view the actual script. And they could run it.

Sucks that you can't just chmod -rwx--x--x to allow 'execution without reading or writing'.
 
Old 08-01-2003, 05:07 AM   #10
kev82
Senior Member
 
Registered: Apr 2003
Location: Lancaster, England
Distribution: Debian Etch, OS X 10.4
Posts: 1,263

Rep: Reputation: 51
you could put the script in a c string and then call system on it eg:
Code:
#include <stdlib.h>

int main()
{
    char *myScript = "script commands go here";
    system(myScript);
    return 0;
}
and then compile the above but it wouldnt be too hard to find out the script from the executable if you knew what you were doing.
Quote:
BUT i dont want them to see / alter my code BUT they should be able to run the file (shell).
why not? if they can see/modify your code maybe they can improve your script in some way and with every improvement the whole office benefits.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
What is Bash shell? xailer Linux - Newbie 4 11-23-2003 09:29 AM
Bash Shell triplem Linux - Software 4 04-17-2003 05:11 PM
Bash shell triplem Linux - Software 1 04-14-2003 08:01 AM
Bash shell problems Regulator Programming 2 03-29-2002 04:53 PM
Help!!!!! Bash Shell???? DarkHorse Linux - Newbie 7 06-04-2001 12:13 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:56 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration