12-10-2018
How to block first bash script until second bash script script launches web server/site?
I'm new to utilities like socat and netcat and I'm not clear if they will do what I need.
I have a "compileDeployStartWebServer.sh" script and a "StartBrowser.sh" script that are started by emacs/elisp at the same time in two different processes.
I'm using Cygwin bash on Windows 10.
My compileDeployStartWebServer.sh compiles the java code and starts the web server on port 8080.
Presently, the "StartBrowser.sh" sleeps for 40 seconds and launches a browser like Chrome or Firefox while the "compileDeployStartWebServer.sh" downloads any dependencies using maven or gradle, compiles the code and starts the web server. This takes a while!
So my plan was to enhance the java startup code in the web site to write "starting" to a UDP socket on port 7777. Alternatively, the java startup code could spawn a new child thread to write "starting" to a TCP socket so it the web site startup code won't block on the TCP socket in case I decide to run without the "StartBrowser.sh" script.
So is there a way to enhance the "StartBrowser.sh" to block on the TCP (or UDP) socket instead of sleeping? I could write some more java code, I suppose.
What would you recommend? UDP? TCP? What could I use to block the "StartBrowser.sh" (besides more custom java code) while the other script is busy downloading dependencies, compiling, deploying and starting the web server? flock?, exec? netcat? socat? something else?
Perhaps I should be using mutexes or semaphores instead? I don't think java has good support for these features, however.
Thanks
Siegfried
Last edited by siegfried; 12-10-2018 at 10:25 PM..
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hello,
I want to know is it possible to pass a block of sentence using bash.
For example,
I have a script called Test.sh that takes in $1 and $2.
and I'm calling Test.sh in a.sh
so
in a.sh
Test.sh '' 'This is a sentence'
Because block are separated by space so when I do that, I get... (6 Replies)
Discussion started by: katrvu
6 Replies
2. Shell Programming and Scripting
Hi everyone.
I need to write a script which will download files/folders (a huge collection) to the local file server (centOS 4.4 Server),
and check regularly (every 6 hours or so if any new files are present, or if the old ones were modified to update contents).
Any insights on how to tackle... (2 Replies)
Discussion started by: reminiscent
2 Replies
3. Shell Programming and Scripting
I am using a bash script for CentOS 5.5, I found one and modified it, however I want to block the incoming IP addresses and ALLOW the IP addresses that are blocked to send out email.
I will use an internal network range for an example, 10.10.10.0/24 (if a lot of spam is incoming) from this range... (0 Replies)
Discussion started by: grifs71
0 Replies
4. Shell Programming and Scripting
Hello,
We have to configure servers with a range of IPs which is in itself a subject for another script assistance request -but- we have run into quite a few IP ranges with routing problems lately.
I've been trying to figure out the best way to test a range of IPs, I mean, manually it's not... (4 Replies)
Discussion started by: boxgoboom
4 Replies
5. Shell Programming and Scripting
hello,
i`m new in bash scripting and i getting an error with my little server monitoring script
example of my script:
#!/bin/sh
s1_ats=0
while ; do
sleep 5
s1=`ping -c 1 xxxx.xxxx.xxxx.xxxx | grep 64 | awk '{print $1}'`
if ; then
$s1_ats=0
else
if ; then (2 Replies)
Discussion started by: grauzikas
2 Replies
6. Shell Programming and Scripting
Hello
I'm beginner in the linux scripting and i would like to get help. I want to create a script that can block one or more Port even see all the TCP port. The ports must be blocked even when starting my machine.
Of course requires a second script which will allow the ports that you want to... (0 Replies)
Discussion started by: houstaf
0 Replies
7. Shell Programming and Scripting
Hello,
I'm attempting to run a script on a remote server via SSH but am having issues getting the script to run using proprietary binaries located on the remote server as it keeps complaining that commands are invalid on the local machine. If I run the script locally on the remote server, it... (2 Replies)
Discussion started by: shadyuk
2 Replies
8. UNIX for Dummies Questions & Answers
I wish to be able to give to a client the opportunity to :
0) Turn one of my ubuntu computers into a webserver
1) See a webpage after visiting a url where an external user/client can set a couple of variables (e.g. Number1= ?, Number2=?)
2) By pressing "run" the program runs on my machine
3)... (1 Reply)
Discussion started by: frad
1 Replies
9. Shell Programming and Scripting
Hello to all,
I want to copy from one server to another files of last 24 hours with size between 500MB and 2GB. The code below searches last files in 24 hours.
find . -mtime -1
In order to copy faster I'd like to compress the files before copying them.
How to automate the process of... (8 Replies)
Discussion started by: Ophiuchus
8 Replies
10. Shell Programming and Scripting
hello,
I am trying to refresh my web page which is created in bash script.
I have a HTML page which when press a button calls a bash script. this bash script created the same page with dynamic data.
When pressing the button I am calling to a function that set time out of 7 seconds and and after... (1 Reply)
Discussion started by: SH78
1 Replies
LEARN ABOUT DEBIAN
java-wrappers
JAVA-WRAPPERS(7) Java wrappers JAVA-WRAPPERS(7)
NAME
java-wrappers - capacities shared by java wrapper scripts
DESCRIPTION
Most Java programs are not run directly, but through small shell scripts that take care of various things, such as finding a suitable java
environment and looking for libraries.
To ease the task of the maintainers, they rely on a library providing runtime detection, library detection and other features. This manual
page describes the common features of all those scripts, and to which point you can configure them. This is mainly done via environment
variables.
ENVIRONMENT VARIABLES
java-wrappers understands some environment variables:
JAVA_CMD
The java command that will be run. If this variable is set, it disables all lookup for a java runtime.
JAVA_BINDIR
Specifies a directory that will be looked for a java or a jdb executable (depending on the setting of JAVA_DEBUGGER). It has prece-
dence over JAVA_HOME but not over JAVA_CMD.
JAVA_HOME
A path to a java runtime. If this variable is set, all lookup for a java runtime is disabled, except that if no java executable is
found in the path, the command java is used.
JAVA_FLAVOR
A probably more easy-to-use version of the JAVA_HOME variable: instead of specifying the full path of the java runtime, you name it.
List of available flavors can be found in the file /usr/lib/java-wrappers/jvm-list.sh. See examples below.
JAVA_DEBUGGER
If this is set, the wrapper will try to pick up a java debugger rather than a java interpreter. This will fail if the jbd of the
runtime found is a stub.
JAVA_CLASSPATH
Additional classpath, will have priority over the one found by the wrapper.
JAVA_ARGS
Additional arguments to the java command. They will come before all other arguments.
FORCE_CLASSPATH
If this variable is set, it will be the only classpath. You'd better know what you are doing.
DEBUG_WRAPPER
This is probably the most important variable; if it set, the wrapper will print out useful information as it goes by its business,
such as which runtime it did find, and which command is run eventually.
JAVA_JARPATH
The path where the wrappers will go looking for jar archives. If not set, the wrapper will look into the default directory,
/usr/share/java. Warning : the wrapper will not look anywhere else than in JAVA_JARPATH. Setting it incorrectly will most probably
result in early crashes.
EXAMPLES
The examples all rely on rasterizer(1), from the package libbatik-java, but they really apply to all scripts that use java-wrappers.
Print out debugging information:
DEBUG_WRAPPER=1 rasterizer
Limit rasterizer's memory to 80 MB:
JAVA_ARGS=-Xmx80m rasterizer
Force rasterizer to run with kaffe(1):
JAVA_HOME=/usr/lib/kaffe rasterizer
The same, but using JAVA_BINDIR:
JAVA_BINDIR=/usr/lib/kaffe/bin rasterizer
Force rasterizer to run with openjdk:
JAVA_FLAVOR=openjdk rasterizer
Debug rasterizer with Sun's debugger, while printing debugging information from the wrapper:
DEBUG_WRAPPER=1 JAVA_CMD=/usr/lib/jvm/java-6-sun/bin/jdb rasterizer
BUGS
Care has been taken to make the wrappers bug-free. If that was not the case, please file a bug report against the java-wrappers package.
If you wish to submit any problem with a java executable relying on java-wrappers, please also submit the output of the command run with
DEBUG_WRAPPER=1. It will save one mail exchange and therefore potentially reduce the time it takes to fix the bug.
DEVELOPERS
There is currently no documentation about writing a wrapper script save the comments in /usr/lib/java-wrappers/java-wrappers.sh. If you
have to write one, we suggest you base yourself upon, for instance, the rasterizer wrapper script, or any other one (just pick up any
direct reverse dependency of java-wrappers and look for scripts).
SEE ALSO
java(1), jdb(1)
/usr/lib/java-wrappers/java-wrappers.sh
AUTHOR
java-wrappers and its documentation were written by Vincent Fourmond <fourmond@debian.org>
Version 0.1.16 2010-05-04 JAVA-WRAPPERS(7)