how can I create a shortcut to a .sh file.

Hi,
I’m trying to change my level from newbie to something else :slight_smile: And I have a question about shortcut commands:

I always use below commands to run my tomcat server:

  1. su -
  2. cd /usr/local/another_folder/tomcat/bin/
  3. ./startup.sh

This is the way I have to repeat at least 20 times in a day. What I can I do for that to ease my life. Thanks.

Just drag and drop the startup.sh into the bin directory in your home folder.

Then you only have type startup.sh 20 times a day.

I would be more concerned what is wrong with the server that it requires 20 restarts a day?

A better idea - install Tomcat 5 from YAST or via zypper.

Then edit /etc/sysconfig/j2ee to point to your tomcat installation - this way you can use rctomcat5 to start / stop the service.

The file varies a bit on your distro version and Tomcat but the essentials are the same.

Hey folks,
Actually I was expecting some “alias” modification on my .profile; therefore, instead of “cd /usr/local/another_folder/tomcat/bin/” I write just e.g. “cd tomfolder”, and for .sh file another alias for “/usr/local/another_folder/tomcat/bin/startup.sh”. But I don’t know how to do it. I looked some tip&tricks websites and applied the things that they said, but didn’t work. So can you help me with aliases? (I think I should modify system-wide file e.g .profile to allow every user to use same aliases)

The tomcat is bundled with a suite that I used, so every modification that I do on it needs restarting Tomcat.
cya,

Hi,

First of all you don’t have to change to the dir where the command is. You can also type:


/usr/local/another_folder/tomcat/bin/startup.sh

wherever you are to start the script. You know how to use TAB on the console?

Why don’t you run tomcat as a daemon? Copy the built in start script to /etc/init.d and go to Yast System runlevel editor to let your computer start it at boot time.

Running tomcat with root rights is really risky. Tomcat should run under a restricted system user.

To learn how to make shortcuts read


man ln

hth

Bye

Erik

I still suggest using the internal tomcat scripts included with the SuSE as they also support user switching to non-privileged u:tomcat,g:tomcat thus giving additional system security in case there’s a security flaw in Tomcat.

What I’ve done:

  1. I chmod’ed tomcat/logs/catalina.out to a+w , because when I try to run startup.sh with my user privileges it gives error like cannot write to catallina.out. So now I can run tomcat without root privileges (I hope I reduced that vulnerability a little bit :slight_smile:

  2. I ln’ed my startup.sh and shutdown.sh with

ln -s /usr/local/xx/tomcat/bin/startup.sh /home/myname/Desktop/startup_tom.sh

2-1) The funny thing is here when I’ve been in the same folder with startup.sh and tried to do:

ln -s ./startup.sh /home/myname/Desktop/startup_tom.sh

I didn’t work! so I write whole path even I was in the same path.

3)When I click the soft links on my desktop it ask me to “run” or “run in a terminal”. What I want to do is I run it on a terminal but not to be closed by itself; therefore there will be a change to trace the log output. Is it possible?

  1. (After Chrysantine’s Entry)To let Tomcat run more secure i.e. creating another user named e.g tomcat with min privileges, then let soft links run on my desktop, is going further to a scripting level, huh?

Cya,

why not have tomcat path in your .bash_profile

export CATALINA_HOME=/path/to/tomcat/folder

then all you have to do is say “catalina run” or “catalina.sh run” from a terminal
OR
write another sh file


$CATALINA_HOME/bin/catalina.sh run > "/path_to_my_log_folder/catalina_run_logs/`date +%d"_"%B"_"%Y"_"%R:%S`"

this way you will have all the output in a file of its own and the filename will be the time the server started

hope this helps
this works for me on RHEL
it probably should work on opensuse too

Running Tomcat as root… No. Just no.

root???
where did i say that?
i run it as a normal user

just coz i’m new to this forum doesn’t mean i’m dumb enough to run everything as root

On Thu, 26 Mar 2009 03:46:01 +0000, vij4yd wrote:

> root???
> where did i say that?
> i run it as a normal user
>
>
> –

Original poster said they were doing a “su -” prior to starting
it…ie, running as root.

Jim

Chrysantine quoted me on that reply.
thats the reason …

As Henders said, it was aimed at the original poster as well - he does su - everytime he wants to launch tomcat because the directories are owned by root (or tomcat if you’re using the Tomcat package) - if you were to simply launch Tomcat with your command line it wouldn’t work (due to permission issues)

The right way to do it is to use the Tomcat package, then modify the scripts - the Tomcat RPM from SuSE creates a non-privileged tomcat user and group, which you can then use on your own Tomcat installation - also it creates a symlink and init script so you can either have it start/stop on shutdown or manually start / restart.

hmm…
a little misunderstanding there
:slight_smile: