ApacheGUI Error ./run.sh: 1: [: -ne: unexpected operator - java

I have installed Apache GUI on Linux Debian in the following directory
/usr/local/apachegui/ApacheGUI/bin
by the following instruction as shown on this webpage:
https://www.howtoforge.com/tutorial/ubuntu-apache-gui/
At the end of the instruction, it's says run the following command:
sudo ./run.sh
when I run the above command I get the following output but with an error
./run.sh: 1: [: -ne: unexpected operator
Bottom of the terminal window its mention tomcat started and as in above mention tutorial webpage claims after running run.sh command
Your ApacheGUI is now starting and listening on port 9999.
Next, open your web browser and type the URL >http://your-server-ip:9999/ApacheGUI. You will >be redirected to the following page (ApachiGUI home page)
In my case when I am typing the above URL with my IP address or localhost my Chrome browser print: output site can not be reach
So I searched to check if port 9999 is enabled and listening in my case I was unable to see port 9999 in my list of ports so ran the following commands and the terminal window didn't produce any output from here I assumed port 9999 is close
pi#Home:~ $ ss -na | grep :9999
After using the above command terminal window return back to ip#home:$
now I open a separate terminal window and ping port 9999 and as result, This terminal window hang now it is clear the port 9999 is not open in my server so to open the close port I run the following command
Open port command:
sudo iptables -A INPUT -p tcp --dport 9999 -j ACCEPT
To update the firewall rules, I restart the iptables service
sudo iptables -L
output:
pi#Home:~ $ sudo iptables -L
Chain INPUT (policy ACCEPT)
target prot opt source destination
ACCEPT tcp -- anywhere anywhere tcp dpt:9999
Chain FORWARD (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
Now I check again a list of open ports on my server and I still can't see port 9999
After taking all these steps executed following command:
pi#Home:/usr/local/apachegui/ApacheGUI/bin $ ./run.sh
Output:
Using CATALINA_BASE: /usr/local/apachegui/ApacheGUI/tomcat Using
CATALINA_HOME: /usr/local/apachegui/ApacheGUI/tomcat Using
CATALINA_TMPDIR: /usr/local/apachegui/ApacheGUI/tomcat/temp Using
JRE_HOME: /usr Using CLASSPATH:
/usr/local/apachegui/ApacheGUI/tomcat/bin/bootstrap.jar:/usr/local/apachegui/ApacheGUI/tomcat/bin/tomcat-juli.jar
Tomcat started.
look like the initial error is resolved but I am still unable access ApacheGUI from my browser still unable to resolve the error mention above can anyone suggest what is the solution to this problem?

The run.sh file is a badly written shell script with content:
if [ $UID -ne 0 ]; then
sudo ../tomcat/bin/startup.sh
exit
fi
exec ../tomcat/bin/startup.sh
Just execute tomcat/bin/startup.sh. This script can fail in many ways:
there is no shebang (#!interpreter_name), so it is executed using /bin/sh or whatever the default shell is,
UID is not a POSIX variable (cf. this question), so the result is blank and test ([) only sees -ne 0. Usually in such cases the variable should be quoted or tested if it is not empty,
the path ../tomcat/bin/startup.sh is relative to the current directory, not the directory of the script.

By executing following tests you will learn port testing and port configuration and at the end of these test you will be able to find out either problem exist within your Server ports or you have to check the setting of your browser. In my case I have taken an unintentional long route, I set my testing plan into three sections as follow
Server Ports and Browser
If you ever experience the same issue my advise is to troubleshoot
Server Browser and then test Ports
By executing tomcat/bin/startup.sh it does start the server successfully just like run.sh (as mention in Question and given answer above) but the browser was still unable to load the localhost:9999/ApacheGUI index page because the server's initial error
./run.sh: 1: [: -ne: unexpected operator
was resolve (as shown in question) but the browser was still unable to load the GUI page so for this reason just to find out if there is a problem with port 9999 itself or there is something else causing localhost not to communicate with the browser via port 9999 I have carried out following tests:
I believe the following information is suitable for a tester who wants to troubleshoot ports but if you think there is nothing wrong with your ports and the problem may lies with the browser then visit the following link Where I had the same problem with port 8080 and I overcome this issue by modifying browser settings:
https://stackoverflow.com/questions/66524719/tomcat10-home-page-can-not-load-by-typing-localhost8080-error-err-connection-r
Reboot my server and execute the following command in terminal
tomcat/bin/startup.sh
output shows
Tomcat started
With this output, I know ApacheGUI is installed and the server is up and running.
Q: if the server is running so whey localhost:9999/ApacheGUI index
page is unable to load?
let's test port 9999 and take the following steps to check either it's port on your machine causing this error or it's something else
StepNO:1
pi#Home:~ $ nc -vz 192.168.0.16 9999
Connection to 192.168.0.16 9999 port [tcp/*] succeeded!
StepNO:2
type command on Linux terminal to test port 9999 (Enter)
pi#Home:~ $ sudo ls | nc -l -p 9999
(Cursor start flashing with no output)
StepNo:3
Then turn ON Window computer and open PuTTY client
Establish SSH connection from window machine by typing the following credentials in PuTTY Client interface:
Server: 192.168.0.16 port 9999
(Press Enter)
if port 9999 is open successfully you will get the following results
Linux Server Terminal (StepNO:2) Where cursor was flashing start responding to
Client request and print following line (where the cursor is still flashing):
SSH-2.0-PuTTY_Release_0.74
StepNO:4
Open a new terminal window and typed another command to make sure port 9999 is definitely open and responding (Linux Server terminal in StepNO:2 still open)
pi#Home:~ $ nmap -p 9999 192.168.0.16
Output:
Starting Nmap 7.70 ( https://nmap.org ) at 2021-03-05 23:44 GMT Nmap
scan report for 192.168.0.16 Host is up (0.00049s latency).
PORT STATE SERVICE 9999/tcp open abyss
Nmap done: 1 IP address (1 host up) scanned in 0.26 seconds
This stage confirmed I have successfully open port 9999 and the port is responding to
TCP protocols
StepNO:5
in the same Linux server terminal (stepNO:2) I type the following command again:
sudo ls | nc -l -p 9999 (Enter)
(Cursor start flashing)
Now I have open the browser and type ApacheGUI URL
192.168.0.16:9999/ApacheGUI (Enter)
Linux server terminal from StepNO:2 where the cursor is flashing start responding to
URL request from the browser and print the following lines in the terminal window:
Output:
GET /ApacheGUI/ HTTP/1.1 Host: 192.168.0.16:9999 Connection:
keep-alive Upgrade-Insecure-Requests: 1 User-Agent: Mozilla/5.0 (X11;
Linux armv7l) AppleWebKit/537.36 (KHTML, like Gecko)
Chrome/86.0.4240.197 Safari/537.36 Accept:
text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,/;q=0.8,application/signed-exchange;v=b3;q=0.9
Accept-Encoding: gzip, deflate Accept-Language: en-US,en;q=0.9
But: my ApacheGUI index page still unable to load and showing the following error message
This site can’t be reached192.168.0.16 refused to connect. Try:
Checking the connection Checking the proxy and the firewall
ERR_CONNECTION_REFUSED
At this stage, I am 100% sure that my installed server is up and running. Port 9999 in my server is open and functional so there is nothing else that can cause this error except the browser so I have followed the step to tune my browser setting as described in answer to the following link:
https://stackoverflow.com/questions/66524719/tomcat10-home-page-can-not-load-by-typing-localhost8080-error-err-connection-r
Result: Successful connection ApacheGUI index page finally loaded to the browser.

Related

Cannot find mysql.sock file and cannot check if mysql is running on mac using xampp

I am extremely new to Computer Science, and we were asked by our professor to connect our java file to our MySQL database using XAMPP. My java file would not connect to the database I created on phpmyadmin no matter what I did, so I tried to get to the root of the problem by entering mysqladmin -u root -p ping on my terminal. This was the result:
error: 'Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)'
Check that mysqld is running and that the socket: '/tmp/mysql.sock' exists!
I went to my tmp folder and could not find the mysql.sock file. I tried checking if mysql was running by entering ps aux | grep mysql on my terminal. The result was
username 5078 0.0 0.0 4277504 672 s001 S+ 11:21AM 0:00.00 grep mysql
but I have no idea what that means. I also tried commands like service mysql restart and sudo service mysqld start, but terminal would say
zsh: command not found: service
I tried locating for the mysql.sock file because I thought it was just misplaced, so I entered locate mysql.sock and netstat -ln | grep mysql on the terminal, but they returned nothing. I also tried mysqladmin -p -u <user-name> variables but the result again was
mysqladmin: connect to server at 'localhost' failed
error: 'Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)'
Check that mysqld is running and that the socket: '/tmp/mysql.sock' exists!
The weird thing is that on the Log tab of XAMPP, it says INFO: Successfully started "mysql". I am also able to connect to my databases using my php projects, but I just can't connect with my java files. Please help, I am desperate.

Appium Question. If "listen eaddrinuse: address already in use", how to stop it? why it didn't stop?

I had been started Appium using default 0.0.0.0:4723 address and port, but then I got this error:
C:\User\me>appium
[Appium] Welcome to Appium v1.17.0
[HTTP] Could not start REST http interface listener. The requested port may already be in use. Please make sure there is no other instance of this server running already.
Fatal Error: listen EADDRINUSE: address already in use 0.0.0.0:4723
at Server.setupListenHandle [as _listen2] (net.js:1309:16)
at listenInCluster (net.js:1357:12)
at doListen (net.js:1496:7)
at processTicksAndRejections (internal/process/task_queues.js:85:21)
I found that I can change the port using:
appium -p 4724
I also found that I can close connection to 0.0.0.0:4723, if any, whether on the Appium desktop app or a second CMD. I closed Appium desktop app, I stopped and closed any other CMD, but I still got the same Fatal Error: listen EADDRINUSE: address already in use 0.0.0.0:4723
Then my questions: How to stop this already used address? and, Why it didn't stop?
I am ok with using another port to start my server, but shouldn't I be able to simply stop the connection to 4723 port and using it again?
Open a CMD window in Administrator mode by navigating to Start > Run > type cmd > right-click Command Prompt, then select Run as administrator.
C:\Users\admin>netstat -ano|findstr "PID :4723"
Proto Local Address Foreign Address State PID
TCP 0.0.0.0:4723 0.0.0.0:0 LISTENING 6134
To kill the process type the PID of the port you want to kill (which will be displayed on the CMD screen)
[/f is force]
taskkill /pid 6134 /f
It means that port is already in use. You must kill the process running in that port.
Type following in your command prompt/terminal to get the process ids(PID).
ps aux | grep appium
Then kill that process with following command
kill -9 PID
Alternate process for window:
netstat -ano | findstr :4723
tskill typeyourPIDhere
taskkill /F /IM node.exe
Instead of remembering and getting to know the process id, just execute the above in command line and Appium service will be ended.

Docker port isn't accessible from host

I have a new Spring Boot application that I just finished and am trying to deploy it to Docker. Inside the container the application works fine. It uses ports 9000 for user facing requests and 9100 for administrative tasks like health checks. When I start a docker instance and try to access port 9000 I get the following error:
curl: (56) Recv failure: Connection reset by peer
After a lot of experimentation (via curl), I confirmed in with several different configurations that the application functions fine inside the container, but when I try to map ports to the host it doesn't connect. I've tried starting it with the following commands. None of them allow me to access the ports from the host.
docker run -P=true my-app
docker run -p 9000:9000 my-app
The workaround
The only approach that works is using the --net host option, but this doesn't allow me to run more than one container on that host.
docker run -d --net=host my-app
Experiments with ports and expose
I've used various versions of the Dockerfile exposing different ports such as 9000 and 9100 or just 9000. None of that helped. Here's my latest version:
FROM ubuntu
MAINTAINER redacted
RUN apt-get update
RUN apt-get install openjdk-7-jre-headless -y
RUN mkdir -p /opt/app
WORKDIR /opt/app
ADD ./target/oauth-authentication-1.0.0.jar /opt/app/service.jar
ADD config.properties /opt/app/config.properties
EXPOSE 9000
ENTRYPOINT java -Dext.properties.dir=/opt/app -jar /opt/app/service.jar
Hello World works
To make sure I can run a Spring Boot application, I tried Simplest-Spring-Boot-MVC-HelloWorld and it worked fine.
Netstat Results
I've used netstat to do port scans from the host and from the container:
From the host
root#my-docker-host:~# nmap 172.17.0.71 -p9000-9200
Starting Nmap 6.40 ( http://nmap.org ) at 2014-11-14 19:19 UTC Nmap
scan report for my-docker-host (172.17.0.71)
Host is up (0.0000090s latency).
Not shown: 200 closed ports
PORT STATE SERVICE
9100/tcp open jetdirect
MAC Address: F2:1A:ED:F4:07:7A (Unknown)
Nmap done: 1 IP address (1 host up) scanned in 1.48 seconds
From the container
root#80cf20c0c1fa:/opt/app# nmap 127.0.0.1 -p9000-9200
Starting Nmap 6.40 ( http://nmap.org ) at 2014-11-14 19:20 UTC
Nmap scan report for localhost (127.0.0.1)
Host is up (0.0000070s latency).
Not shown: 199 closed ports
PORT STATE SERVICE
9000/tcp open cslistener
9100/tcp open jetdirect
Nmap done: 1 IP address (1 host up) scanned in 2.25 seconds
The container is using Ubuntu
The hosts I've replicated this are Centos and Ubuntu.
This SO question seems similar but had very few details and no answers, so I thought I'd try to document my scenario a bit more.
I had a similar problem, in which specifying a host IP address as '127.0.0.1' wouldn't properly forward the port to the host.
Setting the web server's IP to '0.0.0.0' fixes the problem
eg - for my Node app - the following doesn't work
app.listen(3000, '127.0.0.1')
Where as the following does work:
app.listen(3000, '0.0.0.0')
Which I guess means that docker, by default, is exposing 0.0.0.0:containerPort -> local port
You should run with docker run -P to get the ports to map automatically to the same values to set in the Dockerfile.. Please see http://docs.docker.com/reference/run/#expose-incoming-ports

Use port which is already in allocated to some process [duplicate]

When I run my Java project using Netbeans I get the following error:
Deployment error:
Starting of Tomcat failed, the server port 8080 is already in use.
See the server log for details.
at org.netbeans.modules.j2ee.deployment.devmodules.api.Deployment.deploy(Deployment.java:166)
at org.netbeans.modules.j2ee.ant.Deploy.execute(Deploy.java:104)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
at sun.reflect.GeneratedMethodAccessor619.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:105)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.Target.execute(Target.java:357)
at org.apache.tools.ant.Target.performTasks(Target.java:385)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1329)
at org.apache.tools.ant.Project.executeTarget(Project.java:1298)
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
at org.apache.tools.ant.Project.executeTargets(Project.java:1181)
at org.apache.tools.ant.module.bridge.impl.BridgeImpl.run(BridgeImpl.java:277)
at org.apache.tools.ant.module.run.TargetExecutor.run(TargetExecutor.java:460)
at org.netbeans.core.execution.RunClassThread.run(RunClassThread.java:151)
Caused by: org.netbeans.modules.j2ee.deployment.impl.ServerException: Starting of Tomcat failed, the server port 8080 is already in use.
at org.netbeans.modules.j2ee.deployment.impl.ServerInstance._start(ServerInstance.java:1297)
at org.netbeans.modules.j2ee.deployment.impl.ServerInstance.startTarget(ServerInstance.java:1251)
at org.netbeans.modules.j2ee.deployment.impl.ServerInstance.startTarget(ServerInstance.java:1062)
at org.netbeans.modules.j2ee.deployment.impl.ServerInstance.start(ServerInstance.java:939)
at org.netbeans.modules.j2ee.deployment.impl.TargetServer.startTargets(TargetServer.java:428)
at org.netbeans.modules.j2ee.deployment.devmodules.api.Deployment.deploy(Deployment.java:143)
... 16 more
BUILD FAILED (total time: 4 seconds)
I tried changing the server port to 8081 and shutdown port in tool->server. It runs fine but again if I do any operations and run the project it says "Deployment error:Starting of Tomcat failed, the server port 8081 is already in use"
What would be the problem?
goto command prompt
netstat -aon
for linux
netstat -tulpn | grep 'your_port_number'
it will show you something like
TCP 192.1.200.48:2053 24.43.246.60:443 ESTABLISHED 248
TCP 192.1.200.48:2055 24.43.246.60:443 ESTABLISHED 248
TCP 192.1.200.48:2126 213.146.189.201:12350 ESTABLISHED 1308
TCP 192.1.200.48:3918 192.1.200.2:8073 ESTABLISHED 1504
TCP 192.1.200.48:3975 192.1.200.11:49892 TIME_WAIT 0
TCP 192.1.200.48:3976 192.1.200.11:49892 TIME_WAIT 0
TCP 192.1.200.48:4039 209.85.153.100:80 ESTABLISHED 248
TCP 192.1.200.48:8080 209.85.153.100:80 ESTABLISHED 248
check which process has binded your port. here in above example its 248 now if you are sure that you need to kill that process fire
Linux:
kill -9 248
Windows:
taskkill /f /pid 248
it will kill that process
If you are behind a proxy server this issue could happen
i had the same issue and was solved by:
Preferences -> General -> Proxy Settings -> No Proxy.
"Maybe the tomcat ready-message was sent to the proxy - and never reached the IDE."
found #: https://netbeans.org/bugzilla/show_bug.cgi?id=231220
I had the same problem when trying to deploy, tomcat failed to restart as Tomcat instance was running. Close the IDE and check TASk Manager - kill any javaw process running, that solved the problem for me.
Take a look on your running processes, it seems like your current Tomcat instance did not stop. It's still running and NetBeans tries to start a second Tomcat-instance.
Thats the reason for your exception, you just have to stop the first instance, or deploy you code on the current running one
By changing proxy settings to "no proxy" in netbeans the tomcat prbolem got solved.Try this it's seriously working.
If on Linux you can kill existing Tomcats with this script
#/bin/bash
if [ `whoami` != root ]; then
echo "Please run this script as root or using sudo"
exit
fi
echo
echo "finding proceses that have name java and established connections status"
echo
echo "Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name"
netstat --tcp --programs | grep "ESTABLISHED" | grep "java"
echo
echo "finding proceses that use port 8080 or http-alt"
echo
netstat --tcp --programs | grep ':8080\|:http-alt'
echo -n "Do you wish to kill a process listed above?[Y/n]"
read choose
if [ "$choose" = "Y" ] || [ "$choose" = "y" ] || [ -z "$choose" ]
then
echo "enter pid to kill"
read procesId
kill -9 $procesId
fi
echo "done exiting"
exit 0
Kill the previous instance of tomcat or the process that's running on 8080.
Go to terminal and do this:
lsof -i :8080
The output will be something like:
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
java 76746 YourName 57u IPv6 0xd2a83c9c1e75 0t0 TCP *:http-alt (LISTEN)
Kill this process using it's PID:
kill 76746
Select the project -> Right-Click -> clean and build and then run the project again simply solve the problem for me.
As, multiple process could bind the same port for example port 8086, In that case I have to kill all the processes involved with the port with PID. That might be cumbersome.
Change your default port in [tomcat_home_dir]/conf/server.xml
find
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
change it to
<Connector port="8090" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
Change your Tomcat port address to 8084 and Shut Down Port to 8025. This will resolve your problem.
In other cases antivirus programs may cause problems. I had this problem with K7 total security. In my case K7 Firewall was blocking the 8084 port. The simple solution is to add an exception to Netbeans in K7 Firewall list.
In order to do that, open K7 and goto Settings -> Firewall Settings -> select Applications tab and find Netbeans.
Select Netbeans and click on edit link. On next screen select Grant Full Network access radio button.
Now goto Netbeans and start the server.
I resolved it by replacing Tomcat 8.5.* with Tomcat 7.0.* version.
This error message can also be caused by SELinux. Check if SELinux is enabled with getenforce
You need to adjust SELinux to use your port and restart.
I.E.
semanage port -a -t http_port_t -p tcp 9080 2>/dev/null || semanage port -m -t http_port_t -p tcp 9080
I tried No Proxy Settings , killing the process id . Some times they do work, But unfortunately they did not this time. So I tried the following.
In the Services Tab in NetBeans - Right Click on Apache Server {Version} - Platform Tab - Uncheck "Use IDE Proxy Settings". This solved the issue in my case.
I also had this problem. I changed port and did other things, but they didn't help me. In my case, I connected Tomcat to IDE after installing Netbeans (before). I just uninstalled Netbeans and Tomcat after that I reinstall Netbeans along with Tomcat (NOT separately). And the problem was solved.

Running Single instance AppScale in a virtual machine

I was trying to run AppScale in a Single-instance node installed in a Vmware box and running the appscale-tools in the same server virtual machine and got this error:
root#appscale:~appscale-tools-bin# ./appscale-run-instances --ips ips.yaml
About to start AppScale over a non-cloud environment.
Head node successfully created at 127.0.0.1. It is now starting up cassandra via the command line arguments given.
Generating certificate and private key
Starting server at 127.0.0.1
Please wait for the controller to finish pre-processing tasks.
Warning: Permanently added '127.0.0.1' (RSA) t othe list of known host.
Error: Couldn't find me in the node map
The solution I was advised was to change a code in this source:
appscale/AppController/lib/helperfunctions.rb
And look for self.local_ip() and change to:
def self.local_ip()
return "127.0.0.1"
end
But when I run
./appscale-run-instances --ips ips.yaml
I am not sure, but it just keep on saying:
"Please wait for the controller to finish pre-processing tasks." for several minutes already.
So I decided to terminate it, and here is what I get:
"...common_functions.rb:399:in 'sleep_unti_port_is_open"
In this case, it seems I need to open a port, I am running AppScale from within Ubuntu, what port should I open in my server?
Here's the complete command line:
./appscale-run-instances --ips ips.yaml
About to start AppScale over a non-cloud environment.
Head node successfully created at 127.0.0.1.
It is now starting up cassandra via the command line arguments given.
Generating certificate and private key.
Starting server at 127.0.0.1
Please wait for the controller to finish pre-processing tasks.
^C./../lib/../lib/common_functions.rb:399:in sleep': Interrupt
from ./../lib/../lib/common_functions.rb:399:in 'sleep_until_port_is_open'
from ./../lib/../lib/common_functions.rb:397:in 'loop'
from ./../lib/../lib/common_functions.rb:397:in 'sleep_until_port_is_open'
from ./../lib/../lib/common_functions.rb:1359:in 'start_appcontroller'
from /usr/lib/ruby/1.8/timeout.rb:62:in ttimeout.
from ./../lib/../lib/common_functions.rb:1351:in 'start_appcontroller'
from ./../lib/../lib/common_functions.rb:548:in 'start_head_node'
from ./../lib/appscale_tools.rb:284:in trun_instances'
from ./appscale-run-instances:14
Using the pre-build Appscale images here or following the steps listed here https://github.com/AppScale/appscale/wiki/Virtualized-Cluster will solve this problem.
Also it has the build script:
$ sudo su
# cd /root
# wget -O - http://bootstrap.appscale.com | sh

Categories

Resources