Some simple Unix / OS X Questions

S

starrin

Guest
Okay -- I am trying to become as efficient in my software development on my mac than I am in Windows.

Where I have trouble is in configuration and command line stuff.

For instance when I start a .bat file in Window (say - running a Servlet Engine like Tomcat) all the local process debug information goes to the screen.

But when I use the .sh file in OS X from the command line - I get some startup parameters and then it starts in the background -- how do I get it so that I am getting all that good startup and debug information on my Terminal window as it is running -- I guess I am trying to figure out how to run it within the Terminal window.

I was assuming it would off bat -- maybe the startup.sh file that starts the server is putting it in the background?

Thanks for any help.

Jason
 

rman


Retired Staff
Joined
Dec 24, 2002
Messages
12,637
Reaction score
168
Points
63
Location
Los Angeles, California
Your Mac's Specs
14in MacBook Pro M1 Max 32GB 2TB
The script that you are running is run in the foreground, unless you put it in the background. What you need to do is trun on the verbose option. It has been a long time since I have written any shell scripts. I think for bourne shell, you run it with the -x option, but I would check to be sure (i.e. sh -x yourfilename).
 
OP
M

MoltenLava

Guest
starrin said:
I was assuming it would off bat -- maybe the startup.sh file that starts the server is putting it in the background?

Without looking at what the script does I can only speculate, but I would say that's the most likely reason. Unix servers are traditionally made run in the background by default. And there is no standardized option to make the server process run in the foreground. Take a look at the script. Well written script should provide -h or -help option to show the available options, and in many cases you'll find the answer there.
 
Joined
Feb 25, 2004
Messages
475
Reaction score
3
Points
18
Location
Portland, OR
Your Mac's Specs
15" MacBook Pro, 13" MacBook Black, 15" iMac G4, 24" iMac (soon!)
You just need to turn on the verbose options, as rman said. This is done with "-v". You'll find all the information you need by typing "man sh" at a command prompt, or you can find the SH manual pages online, here
 
OP
S

starrin

Guest
Hi everyone -- thank you for the input. I do not think this script will output the output it sends to the logfile -- I have to look at the startup script to see if I can send parameters.

One thing I did do is create a script that will automatically 'tail -f' the output file.

One more question though -- how would one create a shell script that will set up a bunch of environment variables and then when the script is done the terminal window keeps the settings. I am exporting certain variables such as the following:

export JAVA_HOME=/Library/Java/Home

but when it returns from the script - it does not hold the environment variables????
 

rman


Retired Staff
Joined
Dec 24, 2002
Messages
12,637
Reaction score
168
Points
63
Location
Los Angeles, California
Your Mac's Specs
14in MacBook Pro M1 Max 32GB 2TB
If you use the saqme values all the time, you may want to create a .profile file. Which contains all of your defined environment variables. This file is located in your home directory. Hopefully, someone will be able to answer your question.
 
OP
M

MoltenLava

Guest
starrin said:
Hi everyone -- thank you for the input. I do not think this script will output the output it sends to the logfile -- I have to look at the startup script to see if I can send parameters.

One thing I did do is create a script that will automatically 'tail -f' the output file.

One more question though -- how would one create a shell script that will set up a bunch of environment variables and then when the script is done the terminal window keeps the settings. I am exporting certain variables such as the following:

export JAVA_HOME=/Library/Java/Home

but when it returns from the script - it does not hold the environment variables????

When you RUN a script, it will fork a shell process, then the script sets the env variables. When the forked shell process dies, the new variables go with it.

What you want to do is "source" a script. There are variations depending on type of the shells, and on bash you just type

# source <script name>

Yes, you can keep it permanent by adding it to your .profile or .bashrc.
 

rman


Retired Staff
Joined
Dec 24, 2002
Messages
12,637
Reaction score
168
Points
63
Location
Los Angeles, California
Your Mac's Specs
14in MacBook Pro M1 Max 32GB 2TB
To add to what MoltenLava stated:

for cshell (csh), bourne shell (sh)

source filename

for korn shell (ksh)

. filename
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top