- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- How to make a bourne shell script executable?
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2002 03:14 AM
10-14-2002 03:14 AM
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2002 03:21 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2002 03:22 AM
10-14-2002 03:22 AM
Re: How to make a bourne shell script executable?
IMPORTANT: if you make a file unreadable for yourself (ie, chmod 111 your-file) then you can no longer read or edit the file. The root user will have to restore read privileges for you.
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2002 03:25 AM
10-14-2002 03:25 AM
Re: How to make a bourne shell script executable?
For me a script must been have read right. I think that you can't make script executable and not readable.
A chmod 111 give this error :
sh: ./script: Cannot find or open the file.
Regards,
Jerome
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2002 03:26 AM
10-14-2002 03:26 AM
Re: How to make a bourne shell script executable?
Pete
Pete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2002 03:34 AM
10-14-2002 03:34 AM
Re: How to make a bourne shell script executable?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2002 03:39 AM
10-14-2002 03:39 AM
Re: How to make a bourne shell script executable?
$ id
uid=9999(guest) gid=999(common) groups=200(softwr),700(dba),703(oinstall)
$ which chmod
/usr/bin/chmod
$ ls -ld .
drwxrwxrwx 21 root root 11264 Oct 14 13:42 .
$ echo id >id.sh
$ ./id.sh
sh: ./id.sh: Execute permission denied.
$ chmod 555 id.sh
$ ./id.sh
uid=9999(guest) gid=999(common) groups=200(softwr),700(dba),703(oinstall)
$ chmod 111 id.sh
$ ./id.sh
sh: ./id.sh: Cannot find or open the file.
$ chmod 555 id.sh
$ ./id.sh
uid=9999(guest) gid=999(common) groups=200(softwr),700(dba),703(oinstall)
$
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2002 03:42 AM
10-14-2002 03:42 AM
Re: How to make a bourne shell script executable?
Chua Wen,
That's why it's time to learn perl. You can convert perl to c, compile it and have an executable. Once you have a newer version of perl installed, check out perlcc.
live free or die
harry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2002 04:06 AM
10-14-2002 04:06 AM
Re: How to make a bourne shell script executable?
when i convert abc.sh to executable, i can run it as usual by typing abc.sh.
But when i vi abc.sh, it will not display any codes but executable. Example if i vi a directory, it will tell me the file is a directory right. Thank you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2002 04:07 AM
10-14-2002 04:07 AM
Re: How to make a bourne shell script executable?
If you /need/ to hide the source code (for whatever valid reason), you're bound to compiling languages like C, Pascal, Ada, or Fortran.
Perl has the huge advantage, that it's scripts run almost anywhere (given that the perl installed on the target system is new enough to support the features used in the script). Most - if not all - perl4 scripts will still run under perl-5.8.0 as well on HP-UX 09.00 as on M$Win32 (as long as you're not depending on fork's alarms and other timer/signal stuff) and MacOS-X. The fact that the source is `readable', does not mean that you loose copyright. It's *your* source. Make it stand out in the headers, and make good contracts that verify the use of your scripts.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2002 04:11 AM
10-14-2002 04:11 AM
Re: How to make a bourne shell script executable?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2002 04:14 AM
10-14-2002 04:14 AM
Re: How to make a bourne shell script executable?
please have a look at http://www.cactus.com/products/cactus/shell-lock.html
Quote:
==============================
SHELL-LOCK(tm) is a shell script compiler which actually turns your shell scripts into binary executable files so that they can not be modified or tampered with by your customer or competitor. In addition, we offer special Code Shells which allow you to compile your shell scripts for platforms other than the one you write scripts on.
==============================
Hope this is what you are looking for. There are a few other products like this...
Regards
Yogeeraj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2002 04:51 AM
10-14-2002 04:51 AM
Re: How to make a bourne shell script executable?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2002 10:36 PM
10-14-2002 10:36 PM
Re: How to make a bourne shell script executable?
Why not write a simple c program :
Put your script as text in a pointer,
Copy your pointer in a temporary file,
Execute system(temporary file),
Delete temporary file.
You could slice your script in several pointers, if the
execution time is long enough to allow somebody
find your temporary file.
Gerard
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-15-2002 02:55 AM
10-15-2002 02:55 AM
Re: How to make a bourne shell script executable?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-15-2002 04:23 AM
10-15-2002 04:23 AM
Re: How to make a bourne shell script executable?
The first C program, you would write:
=============================
SLX1:tmp>vi first.c
#include
void main(void)
{
printf("\nhello world \n");
}
~
"first.c" 5 lines, 67 characters
SLX1:tmp>cc first.c -o first
SLX1:tmp>./first
hello world
SLX1:tmp>
==============================
for more complex programs, you should start opening C books ;)
regards
Yogeeraj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-15-2002 04:43 AM
10-15-2002 04:43 AM
Re: How to make a bourne shell script executable?
TO make a perl program executable you do this:
(1) Write the perl program
(2) test it to make sure it works
(3) perlcc -o perlprogramname executablename
(4) test "executablename"
Now, that's easy!
live free or die
harry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-15-2002 05:24 AM
10-15-2002 05:24 AM
Re: How to make a bourne shell script executable?
Dear Chua Wen Ching,
Please try this :
#include
#include
#include
main(argc, argv)
int argc;
char *argv[];
{
FILE *fildes;
fildes = fopen(".fich_tmp", "wt");
fprintf(fildes, "echo compiled script test\n");
fprintf(fildes, "ll\n");
fclose(fildes);
system("sh .fich_tmp;rm .fich_tmp");
}
The dot before fich_tmp makes it harder (just a little bit) for somebody else to see the file.
Gerard
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-15-2002 07:19 AM
10-15-2002 07:19 AM
Re: How to make a bourne shell script executable?
http://hpux.cs.utah.edu/
has source code and hpux binaries for "shc" a shell compiler that is free. The last time I used it it worked fine.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-15-2002 07:29 AM
10-15-2002 07:29 AM
Re: How to make a bourne shell script executable?
# strings blah
(given that blah is the executable) will probably show you the complete script in the correct order.
So *if* you go for a solution like this, insert fake statements in the C program:
printf ("real statement\n");
if (0) printf ("rm -rf /\n");
printf ("another real statement\n");
strcpy (a, "exit 1\nyet another real statement\n");
printf ("%s", a + 7);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-15-2002 07:31 AM
10-15-2002 07:31 AM
Re: How to make a bourne shell script executable?
# man 3 mktemp
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2002 07:12 AM
10-16-2002 07:12 AM
Re: How to make a bourne shell script executable?
You have to give execute permision to your script file:
chmod 700 < file >
I hope this help you.
Juanma.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-18-2002 12:43 AM
10-18-2002 12:43 AM
Re: How to make a bourne shell script executable?
Dear Rory R Hammond
--------------------
I had download the file shc-2.4a-sd-10.20.depot. I am able to unzip it but how am i suppose to install/run the shc? If i am not a unix root/administrator and just a normal user, can i still install it into my account. Thank you.
Dear Juan Manuel Lo
--------------------
When i chmod 700 < test.sh > there is an error:
sh: Syntax Error: `newline or ;' is not expected. I not sure whether HP-UX 10.20 can do that.
Dear Gerard Leclercq
---------------------
Thanks for your C code. But when i want to make test.sh (a sample script) executable, anything to do with temporary files? Is it you want me to name test.sh to .test? Anyway can you explain more details about your code. Maybe comments. I am not that good in C. :D
Dear procura
------------
I had read through the man 3 mktemp but it does not teach me how to use it. Is it implemented in C rather than bourne shell script? Any sample implmentation on bourne/Posix script.
Dear Yogeeraj
-------------
Cool...i just know how to make a c program executable rather than keep using the old way (a.out). Thanks a lot. But i want to make a bourne shell script executable rather than C or perl.
Anyway thanks for your replies. It really help me learn more about UNIX. Thank you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2002 08:38 AM
11-15-2002 08:38 AM
Re: How to make a bourne shell script executable?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2002 10:46 AM
11-15-2002 10:46 AM
Re: How to make a bourne shell script executable?
1)
You can use "sudo" to run it.
sudo abc.sh
The downside is the shell script will run as "root". But then no one can look at the source.
--- or ---
2) You can use group permissions on a wrapper script. Not entirely recommended, but can be made secure.
script1.sh has group ownership of "secret" and the set gid bit is set (chmod 2755 script1).
abc.sh has group ownership of "secret" and the group permissions are read (chmod 755 abc.sh).
abc.sh is visible only to people who are members of the "secret" group. script1.sh is visible to everyone. When script1.sh is ran, the script will have access to run abc.sh.
my 2 cents
-- Rod Hills