How to discover where localhost points to? - windows

I have the following link:
http://127.0.0.1:61374/wse/wsexplorer/wsexplorer.jsp?org.eclipse.wst.ws.explorer=0
Now since this starts with 127.0.0.1, my browser is showing me a file that is in my computer. I want to learn where this file is.
To do so, I need to learn which directory 127.0.0.1:61374 points to. So, I ran:
netstat -ano
In the output:
TCP 127.0.0.1:61374 127.0.0.1:63216 ESTABLISHED 7228
Then I ran:
tasklist
In the output:
javaw.exe 7228 Console 1 950.936 K
So a Java program is running behind this port. However, where do I go from here to discover where is the file http://127.0.0.1:61374/wse/wsexplorer/wsexplorer.jsp?org.eclipse.wst.ws.explorer=0 in my computer?
I also tried searching the whole computer for wse but the search did not return any directory named wse. Is this normal?

Related

How to display the port numbers of open connections for a specific process with tcpvcon.exe (Windows 10)?

I have both TCPView and Tcpvcon on my Windows 10 machine and I wonder how to get all the information (port numbers, etc.) displayed in TCPView in the output of the Tcpvcon program? TCPView has the process name, PID, protocol, remote address, remote port, etc. in its output to the GUI. Tcpvcon, on the other hand, only contains the process name, protocol, remote and local address. I would like to have all information that can be read in the TCPView GUI in the command line output of Tcpvcon (especially the port numbers). Tcpvcon seems to have only the three switches -a -c -n but no matter how I combine them, I do not reach my goal. Can anyone help me?
Below is a sample output when I use all three switches. In TCPView I see much more information about the specified process.
I was also very surprised that tcpvcon does not show port numbers (maybe we should ask Mark R. to add them ;-)
BUT you could use
netstat -a -o -n
or with an admin shell even
netstat -a -o -n -b
switches meaning:
-a ... Displays all active TCP connections and the TCP and UDP ports
on which the computer is listening.
-o ... Displays active TCP connections and includes the process ID (PID)
for each connection.
-n ... Displays active TCP connections, however, addresses and port numbers
are expressed numerically and no attempt is made to determine names.
-b ... Displays the executable involved in creating each connection or
listening port. (Note that this option can be time-consuming and
will fail unless you have sufficient permissions.)
To get all available switches just use netstat -? (there are other interesting ones) or https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/netstat
swobi
Up until the 2011 release of TCPVCON, it used to show port info.
The newer versions don't any more.
If you could get your hand on version 2.54, you would be able to get port info.
Tested with tcpvcon-v2.34 (I couldn't find 2.54) and it shows the ports but it doesn't show the process, all conections appear as from System. Also TCPV6 and UDPV6 are missing.
This is an example:
C:\WINDOWS\system32>"C:\My Program Files\TCPView-v4.13\tcpvcon-v2.34.exe" -a -c
TCP,System,-1,LISTENING,WXP-OR7507156:epmap,WXP-OR7507156:0
TCP,System,-1,LISTENING,WXP-OR7507156:microsoft-ds,WXP-OR7507156:0
TCP,System,-1,LISTENING,WXP-OR7507156:sms-rcinfo,WXP-OR7507156:0
TCP,System,-1,LISTENING,WXP-OR7507156:5040,WXP-OR7507156:0
TCP,System,-1,LISTENING,WXP-OR7507156:wsd,WXP-OR7507156:0
..
UDP,System,-1,,192.168.56.1:137,*:*
UDP,System,-1,,192.168.56.1:138,*:*
UDP,System,-1,,192.168.56.1:2177,*:*
UDP,System,-1,,192.168.56.1:5353,*:*
EDIT:
I correct myself. ASB was right.
I just got TCPView v2.54 and it does indeed show the application, the ports and also TCPV6 and UDPV6.
So I confirm that the "good" version is v2.54.
Tcpvcon.exe -a -c
TCPView v2.54 - TCP/UDP endpoint viewer
Copyright (C) 1998-2009 Mark Russinovich
Sysinternals - www.sysinternals.com
TCP,dnscrypt-proxy.exe,4188,LISTENING,WXP-XXX:domain,WXP-XXX:0
TCP,[System Process],0,TIME_WAIT,WXP-XXX:domain,localhost:62240
..
UDP,Teams.exe,12632,*,WXP-XXX:58950,*:*
TCPV6,svchost.exe,1232,LISTENING,wxp-XXX:135,wxp-XXX:0
..
UDPV6,svchost.exe,19712,*,wxp-XXX:50836,*:*
UDPV6,System,4,*,wxp-XXX:56736,*:*
To display the port numbers (and the process names) you need the old v2.54 version of tcpvcon.exe
This SysinternalsSuite.zip Archive from the Wayback Machine contains this version:
https://web.archive.org/web/20100201154325/http://download.sysinternals.com/Files/SysinternalsSuite.zip

How to start jscodeshift in inspect mode?

This used to be runnable but recently I'm encounter the following issue.
By running the following command:
node --inspect-brk ./node_modules/.bin/jscodeshift mod.js file.
I am encountering this problem
Debugger listening on ws://127.0.0.1:9229/7e57a2d3-0885-44b3-b51e-b47dc8417d87
For help, see: https://nodejs.org/en/docs/inspector
Debugger attached.
Processing 1 files...
Spawning 1 workers...
Sending 1 files to free worker...
Starting inspector on 127.0.0.1:9229 failed: address already in use
All done.
Results:
0 errors
0 unmodified
0 skipped
0 ok
Time elapsed: 0.035seconds
What worked for me:
Start node-inspector
Install jscodeshift in my local repo as a dev dependency.
put debugger statement in my script
run jscodeshift via node with --debug-brk arg and added --run-in-band jscodeshift param.
For example :-
I entered node
--debug-brk ./node_modules/jscodeshift/bin/jscodeshift.sh -t my-refactor-script.js --run-in-band
If you add a file pattern at the end, it works fine, which in the case of debugging is helpful when you want to test just one trouble file.
I did not test debugging jscodeshift installed via npm -g
The answer that worked for me was installing ndb, https://github.com/GoogleChromeLabs/ndb, and prefixing the command with it.
ndb node --inspect-brk ./node_modules/.bin/jscodeshift mod.js
The reason inspect mode doesn't work is because another process (e.g. another instance of the inspector) is already using the default port (9229), so they're conflicting. Either use a different port for the inspector or kill the process that's currently using the port.
If you use a different port, you'll be able to start the inspector. Just pass the desired port-number (e.g. 39479) to --inspect-brk.
Your example:
node --inspect-brk ./node_modules/.bin/jscodeshift mod.js file.
Could for example be: node --inspect-brk=39479 ./node_modules/.bin/jscodeshift mod.js file.
DANGER: If you need the port 9229, you can kill the process/inspector that's currently using that port, but if you don't know what that process is doing you could damage things: lsof -i TCP:9229 | grep LISTEN | awk '{print $2}' | xargs kill -9

Windows Kill Process By PORT Number [duplicate]

This question already has answers here:
How do I kill the process currently using a port on localhost in Windows? [closed]
(28 answers)
Closed 3 years ago.
I'm using embedded Tomcat server in Spring Tool Suite IDE. My problem is when I run my project there is an error as follows,
***************************
APPLICATION FAILED TO START
***************************
Description:
The Tomcat connector configured to listen on port 8080 failed to start. The port may already be in use or the connector may be misconfigured.
Action:
Verify the connector's configuration, identify and stop any process that's listening on port 8080, or configure this application to listen on another port.
There are some similar questions but none of the answers not working for me.
Solution 1: Kill Process
Run command-line as an Administrator
netstat -ano | findstr :<yourPortNumber>
taskkill /PID <typeyourPIDhere> /F
Solution 2: Change Port
Please Make sure that new port you are going to set for your Application doesn't listen to any other process
Change the port
server.port=8088 # Server HTTP port.
Solution 3:
Another way is to terminate the process (in IDE) and clean and rebuild project.
UPDATE:
For solution 2, Please Make sure that new port you are going to set for your Application doesn't listen to any other process.
How to check Port Status?
Option 1
Run resmon.exe and go to Network -> Listening Port (Also can be viewed on TaskManager)
Option 2
PowerShell
Get-Process -Id (Get-NetTCPConnection -LocalPort portNumber).OwningProcess
cmd
C:\> netstat -a -b
(Add -n to stop it trying to resolve hostnames, which will make it a lot faster.)
-a Displays all connections and listening ports.
-b Displays the executable involved in creating each connection or listening port. In some cases, well-known executables host multiple independent components, and in these cases, the sequence of components involved in creating the connection or listening port is displayed. In this case, the executable name is in [] at the bottom, on top is the component it called, and so forth until TCP/IP was reached. Note that this option can be time-consuming and will fail unless you have sufficient permissions.
-n Displays addresses and port numbers in numerical form.
-o Displays the owning process ID associated with each connection.
I found that the answer by PatelRomil didn't work for me. I found that by running:
netstat -a -o -n
And getting the PID for the port, and then running:
taskkill /F /PID [PID]
Worked for me. Replace [PID] with the value in the table from the previous command.

Avoid a long delay when checking for a file in a disconnected shared directory

When checking if a file exists in a shared directory
if exist \\10.0.0.10\disk\file echo yes
I experience a very long delay in case the shared directory is disconnected.
I need a faster way to perform this check.
I have tried several alternatives
pushd \\10.0.0.10\disk
if exist \\10.0.0.10\disk\nul
net use \\10.0.0.10\disk
...
but all of them fail after an unacceptable long delay
is there any faster (say less than 1 sec) way?
Or is there any net configuration parameter that can change this timeout?
Edited for clarification The problem is not to reconnect to a specific shared folder. The question is to recognize without having to wait long delays, if a file in a shared folder exists.
This is a bat file that collects information from many different sources, user defined, and some of them can be (and eventually very often are) files in shared folders. Some users may configure dozens of possible sources, and some of them might not be not available when the bat is run. So, those locations will be ignored. But I dont want it to impact the overall performance of the process.
You could try to check if the server is up first using ping:
ping 10.0.0.10 -n 1 -w 100
Use %ERRORLEVEL% to check the result, 0 for success, 1 for failure.
I suppose that you can change your location, so it's possible that there is also an ip 10.0.0.10 but it's not the correct device.
You can check first the status of the net use output (findstr can also be used here)
net use | awk '/((Not)|(Connected)).*10.0.0.10\\disk:/{print $1}'
If this fails, you need to check if it's possible to reconnect.
A ping -n 1 10.0.0.10 could help, but it doesn't tell if it's the correct device.
You can check then the MAC of 10.0.0.10 against an expected value, but you should do the dummy ping before to get a reliable result from arp.
arp -a 10.0.0.10 | findstr "12-34-56-12-34-56"
and if this is successful then you can reconnect
net use \\10.0.0.1\disk

Clojure - Can I assign custom name to a process started using 'lein run'

Is there a way to assign a custom name to a process started using the command below
~lein run
The process stared by the above command is as displayed below -
~lsof -i tcp:8082
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
java 96029 <username> 89u IPv6 0xa04954e1ea972891 0t0 TCP *:us-cli (LISTEN)
It's possible though it gets a bit ugly and likely not worth the trouble
You would need to make a symlink to java with an alternate name, and modify lein to call that instead of calling java. You could do this by writing a lein plugin for instance. When Linux starts a process the name of the process it uses the name of the file from which the process was run as the name of the process thereafter, so you need to change the name of the file that gets run to create the process that will open the port, in this case "java".
If all you needed was an easy way to find either the process that opened the port or it's parent process then you could just make a script with a good name that called lein run. This would show up in the output from ps though not from lsof.

Resources