Compiling a bash script

Spinal

MB Enthusiast
Joined
Sep 14, 2004
Messages
4,792
Location
Uxbridge
Car
G350, Duster, S320, 900ss and a few more
Howdy, a quicky here...

I have a very short (1-line) bash script, which I want to give to my users... problem is, I'm used to invoking it from terminal and have forgotten how to compile bash scripts... if I even can from OsX... (basically I want to give them an executable application that they double click on and it runs my one-line script)

Ideas?

M.
 

smartbrabus

Active Member
Joined
May 20, 2003
Messages
556
Location
M3 Corridor
Car
Honda Integra Type-R (DC2)
If you give it suitable permissions, (e.g. chmod 755 <scriptname>), you should just be able to double click it from the Finder.
 

columb

Active Member
Joined
May 11, 2008
Messages
461
Location
Exeter, Devon
Car
W212
chmod +x /path/to/bash_script.sh

Bash is a scripting language and can not be compiled!

Could I see your one-line-script, please? :)

Cheers
Chris
 
OP
OP
Spinal

Spinal

MB Enthusiast
Joined
Sep 14, 2004
Messages
4,792
Location
Uxbridge
Car
G350, Duster, S320, 900ss and a few more
Humm... Problem is, if I give it the "suitable" permissions, TextEdit takes over on the user accounts and opens it for them...

I've removed the extension, in an attempt to stop textEdit from recognising it, but the file is in HFS+ so it has a metadata fork... will need to remove that as well and see... Problem is, it will imply that the user needs to be able to run terminal, which my policy wont allow... grumble...

The one line script is really stupid, all it does is invoke another script, with the right parameters!

so:
Code:
#!/bin/bash
/usr/bin/sendLogon 192.168.1.1 1234 "$UserName"
exit 0
(IP and port number changed for obvious reasons...)

As for it being non-compilable, I thought there were several compilers out there for it... CCsh and aMuleCC spring to mind, neither of which I could get to work though - so that may explain a thing of two :p
M.
 
Last edited:

columb

Active Member
Joined
May 11, 2008
Messages
461
Location
Exeter, Devon
Car
W212
Spinal,

Sorry- don't get me wrong but I don't see your point. Why not to call other script with parameters? And why would you like to compile a script anyway??
Seriously, however smart and long script is - IT IS NOT A PROGRAM (hence dosn't need compiling)!

The tools which you have tried to use are only TRANSLATORS from BASH to C. You still need to review the code and compile it! (there is no need for your script).

Btw. you don't need to use bash interpreter, as this will work in any shell so /bin/sh will do.

Use .sh at the end and do chmod +x (for execute) and everything should be fine.

And more more thing- if other script will exit with error you'd like capture it so why you are doing exit 0?

It doesn't make sense to me.

Cheers
Chris
 

Dryce

MB Enthusiast
Joined
May 17, 2006
Messages
8,618
Car
..
Code:
#!/bin/bash
/usr/bin/sendLogon 192.168.1.1 1234 "$UserName"
exit 0
(IP and port number changed for obvious reasons...)

As for it being non-compilable, I thought there were several compilers out there for it... CCsh and aMuleCC spring to mind, neither of which I could get to work though - so that may explain a thing of two :p
M.

There usually isn't much point in compiling a shell script - primarily because they are based on invoking other programs. You'd need to have the compiler embed the functionality of some programs (eg. test) to noticably improve performance.

The magic '#!' at the top with the interpreter name and execute permissions makes them appear to be self contained programs.
 

smartbrabus

Active Member
Joined
May 20, 2003
Messages
556
Location
M3 Corridor
Car
Honda Integra Type-R (DC2)
You can package up your script as an "Application" using Applescript.

Open the Applescript editor and enter the following:-
Code:
do shell script "/path/to/your/bash_script.sh"

Then do File->Save As, choose "Application" as the file format and bob's your uncle...
 
OP
OP
Spinal

Spinal

MB Enthusiast
Joined
Sep 14, 2004
Messages
4,792
Location
Uxbridge
Car
G350, Duster, S320, 900ss and a few more
Spinal,

Sorry- don't get me wrong but I don't see your point. Why not to call other script with parameters? And why would you like to compile a script anyway??
Seriously, however smart and long script is - IT IS NOT A PROGRAM (hence dosn't need compiling)!

Because I need to be able to copy a "button" to everyone's desktop, whereby whenever they change room without logging out/in (and hence, get a new IP address without logging in again, and hence, without sending their username to the internet filter) they can just click on the "button" and resend their details...

They CANNOT run terminal, only the IT people have terminal on the software whitelist... hence, I need the script to act like a program, even though it may not be (though I disagree with your comment about a script not being a program... but lets not get into that...)

M.
 

Users who are viewing this thread

Top Bottom