User not logged in - login - register
Home Calendar Books School Tool Photo Gallery Message Boards Users Statistics Advertise Site Info
go to bottom | |
 Message Boards » » shell script question Page [1]  
rynop
All American
829 Posts
user info
edit post

Ok I wanna conditionally execute a command in the background from my shell script. Here is what I'm trying to do

BACKGROUND=""
if [ "$OSTYPE" = "linux" ] ; then
BACKGROUND="&"
fi

exec "$JAVA_HOME/bin/java" <all my shit> $BACKGROUND

I would expect if my OSTYPE did equal linux that this command would run in the background, but it does not. If i hardcode '&' after my java call however, it will run in the background. What am i doing wrong???

4/23/2007 10:44:27 AM

darkone
(\/) (;,,,;) (\/)
11610 Posts
user info
edit post

What shell are you using?

Throw in some echo command to check that your variables are being set and to check the results of your if then statements. That should help with troublshooting.

Just out of curiosity, what exactly are you doing where the OS type is something that is variable?

4/23/2007 10:56:20 AM

rynop
All American
829 Posts
user info
edit post

its gettin set right. ive already thrown in echo's to verify.

[q]Just out of curiosity, what exactly are you doing where the OS type is something that is variable?[/q]
not quite sure what ur asking... the OSTYPE is an env variable. its set by a program that ends up calling this shell script.

4/23/2007 10:58:35 AM

rynop
All American
829 Posts
user info
edit post

ok I got the same functionality but not really what I want.

im just calling the entire script with '&' - so from c im doing execShell("myscript.sh &"); My problem is solved but if anyone knows the answer to my question it would be cool to know what I am missing...

4/23/2007 11:25:13 AM

ruffler
Veteran
108 Posts
user info
edit post

on my machine OSTYPE is set to linux-gnu. Check what echo $OSTYPE shows.

4/23/2007 12:30:15 PM

 Message Boards » Tech Talk » shell script question Page [1]  
go to top | |
Admin Options : move topic | lock topic

© 2024 by The Wolf Web - All Rights Reserved.
The material located at this site is not endorsed, sponsored or provided by or on behalf of North Carolina State University.
Powered by CrazyWeb v2.39 - our disclaimer.