File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Mac OS and the fly likes Tomcat shortcuts / aliases on OS X desktop Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Mac OS
Bookmark "Tomcat shortcuts / aliases on OS X desktop" Watch "Tomcat shortcuts / aliases on OS X desktop" New topic
Author

Tomcat shortcuts / aliases on OS X desktop

Unnsse Khan
Ranch Hand

Joined: Nov 12, 2001
Posts: 511
How can one add shortcuts (aliases) to the startup.sh and shutdown.sh for Tomcat/bin files on the Desktop in OS X?

With thanks!
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61187
    
  66

I'm a command-line kind of guy myself, but if you copy the script to your desktop, rename it from .sh to .command, and make sure that it has exec privs, it will become a 'clickable script'.

Bear in mind that its working directory will be your home folder so you may need to adjust the script accordingly.

You might also want to investigate Platypus for OS X, a tool that creates application wrappers for shell scripts.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Elton Hughes
Ranch Hand

Joined: Jun 19, 2003
Posts: 72
Hello All,

There should also be an AppleScript solution, but I do not know how to tell your script about environmental variables. JAVA_HOME for instance.

Anyone have a thought about that?

Elton
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61187
    
  66

Are you having a specific difficulty? When the scripts run they inheret any variables from the shell just as one would expect.
Elton Hughes
Ranch Hand

Joined: Jun 19, 2003
Posts: 72
Hello Bear,

That is what I thought as well. ApplrScript seems to be of a different mind.

Background: I know nothing about AppleScript. I usually start and stop Tomact using a simple script. Works with no problems. I read the initial post in this thread and by pure coincidence later that day I went to the homepage of the Spring framework. They have a page on how to get Spring running on an MacOSX system. The page included instructions on creating an AppleScript to start and stop Tomcat.

Getting Spring to work on MacOSX

I opened Script Editor and entered 'do shell script "echo /usr/local/tomcat/jakarta-tomcat-4.1.27/bin/shutdown.sh | /bin/bash"' in the editor and compiled it. I ran the compiled script and it generated an error. The error is: "The JAVA_HOME environment variable is not defined
This environment variable is needed to run this program".

I am sure there is a simple way to do it. The variable is defined in my .bash_profile. The command 'echo $JAVA_HOME' prints the correct answer.

It might be interesting to solve this riddle, but I am not to worried as I use CLI for most of this anyway.

Thanks,

Elton
[ February 23, 2005: Message edited by: Elton Hughes ]
Elton Hughes
Ranch Hand

Joined: Jun 19, 2003
Posts: 72
Problem with the AppleScript has been solved. A property list was needed in an invisible folder in your home directory. Just follow the instructions in the linked in my earlier post.

Now as for why it was necessary in the first place, I have no idea.



Elton
Unnsse Khan
Ranch Hand

Joined: Nov 12, 2001
Posts: 511
I tried doing the AppleScript by putting this in the script editor:

do shell script "echo /Developer/JavaTools/jakarta-tomcat-5.0.28/bin/startup.sh | /bin/bash"

And when I tried to save it as an application, it still didn't work!

Can anyone help?
Unnsse Khan
Ranch Hand

Joined: Nov 12, 2001
Posts: 511
I already have the .MacOSX directory under ~ and have a .plist file...

When I tried to create a application (Start Tomcat.app), that contained this:

do shell script "sh $CATALINA_HOME/bin/startup.sh"

A Syntax Error dialog box opened which stated:

"A identifier can't go after this identifier."

And after that it wouldn't let me save it...

Any suggestions, comments, feedback?

With thanks,
Elton Hughes
Ranch Hand

Joined: Jun 19, 2003
Posts: 72
Hi Unnsse,

Try using the full path name for your script, instead of the variable. What happens then?

You wiill get it will work, I am sure. If I did, you can.

Best of luck,

Elton
Unnsse Khan
Ranch Hand

Joined: Nov 12, 2001
Posts: 511
Elton,

I still can't get it to work... It still says:

Syntax Error:

"A identifier can't go after this identifier."

I did try the full path this time:

do shell script "echo /Developer/JavaTools/jakarta-tomcat-5.0.28/bin/startup.sh | /bin/bash"

Do I have it as an application? I tried to save it to my Desktop as the executable: "Start Tomcat.app"

I noticed single quotes in your posting surrounding the 'do shell script ...', are they needed?

Also, do I have to check on any of these:

- Run Only
- Startup Screen
- Stay Open

?

What could I possibly be doing wrong? Do I need the "| /bin/bash"?

What possibly am I doing wrong?
Elton Hughes
Ranch Hand

Joined: Jun 19, 2003
Posts: 72
Hi Unnsse,

You have more questions than I can answer. I did save it as a script, but that is all I can remember. I have since dumped it because I use a Bash script to start and stop Tomcat.

As for your other questions, I have no answer. Sorry.

Elton
Pauline McNamara
Sheriff

Joined: Jan 19, 2001
Posts: 4012
    
    6
Originally posted by Bear Bibeault:

You might also want to investigate Platypus for OS X, a tool that creates application wrappers for shell scripts.


We've been trying to use Platypus on a shell script that requires sudo privileges, but it hangs on the sudo. According to someone else who ran into the same thing ( their story) we can't use Platypus to pass in the sudoer's password. Have you come up against this at all? Any tips?


Thanks,
Pauline
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61187
    
  66

Hmmm, no sorry, I haven't tried any sudo-ed commands with Platypus.
Pauline McNamara
Sheriff

Joined: Jan 19, 2001
Posts: 4012
    
    6
Meanwhile we've figured it out. Well, OK, I asked the developer and he clued us in.

Just in case you ever do need to wrap up a script with sudos into a Platypus app, you only need to require admin authentication and then remove the sudos from the script.

Thanks for the original tip, Bear - Platypus really came in handy.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Tomcat shortcuts / aliases on OS X desktop