I have a server that takes whatever data is sent to it and sends it back. With netcat on linux I am able to exectue the nc ip port command with an additional "argument" in a single line:
python -c print("Hello!") | nc ip port
This is equivalent to first running nc ip port to connect to the server, and later typing Hello! in the opened prompt to send the data.
While I know how to pass an output from a script to another script in windows (ex. here), I am fairly unsure how to achieve a similar result using telnet, as telnet ip port opens its own prompt (which means disabling windows commands).
I would like to know if it is at all possible with telnet to achieve what piping in linux does, or if there is a similar, minimalistic software that I could use on windows.
Related
Is there an easy way to use the telnet server from command line?
I can connect with telnet [ip/domain] [port] but is there a telnet equivalent of nc -l -p [port]?
I've tried using netcat for windows but it didn't support ANSI.
I've tried telnet-server but that didn't work.
Is there a native Win7 way of making a telnet server? And if so, how?
The partial answer is net start telnet, though there's no easy way to emulate netcat -e.
EDIT: Just use netcat, it can transmit ansi art, but only telnet can display it.
I'm trying to script the telnet command to log into a server. My problem is that my username is my email so it has an # in it - so something like this fails:
telnet user#email.com#1.1.1.1
I've also tried this but it fails the same way.
set USER=user#email.com
telnet %USER%#1.1.1.1
Is there any way to escape the ampersand or is there another way to pass it to the telnet command? I've tried passing -l as follows but it does not work (as it still prompts me for a username so I'm guessing the telnet server doesn't support that and that would be out of my control to change).
telnet -l user#email.com 1.1.1.1
Ultimately, my goal is to get a doskey script with a command like the following
doskey t=telnet user#email.com#1.1.1.1
EDIT: Originally I mistakenly said ampersand but meant the at (#) symbol.
I want to write a batch script which forwards a local port on my machine to the server, dataexchange. I have given the server my public key for authentication, and I want to connect using plink, PuTTY's command line SSH tool.
Here's what I want the script to do.
Forward the local port 3309 to dataexchange:3306.
Run a Java program on my local machine which queries the mysql database on dataexchange:3306.
Closes the port.
I'm a novice at writing in batch, but here is what I think should work. I am not sure how to run the Java program in batch on my machine, and I am not sure how to close plink after it run.
#ECHO OFF
plink -L 3309:dataexchange:3306 -l myUser -N &
java -jar myprog.java
You have a few things backward in your example:
Your probably want the java program to connect to localhost:3306 which is then forwarded to the remote dataexchange:3306
The Port forwarding syntax is then: -L 3306:localhost:3306
You need a host to connect to in your plink command. In this case probably myuser#dataexchange
There is no & thing in windows, the start command should help you (Doc)
After the java program completes you can then use taskkill /im plink.exe to kill the plink tunnel. (But beware, that kills all plink processes currently running)
The java command is probably also wrong, you can't run .java files without compilation. (Did you write the program yourself? Then compile it first with javac)
I have an app that listens on a localhost port. I want a minimal launcher to bring that app's to the front.
My app is in Java. I don't know how to write any exe files, but I can write bat files, and then make a shortcut that launches the bat file without showing the terminal. I would like to have the bat file send some data to a port (preferably UDP so there will not be any stream overhead).
How can I send data to a UDP port?
One of the things I thought of was nslookup, but that will only connect to port 53 as far as I know.
This only needs to work on Windows. Would like it to work on XP and up, but I can make a workaround if necessary.
This is a job for netcat.
http://nc110.sourceforge.net/
After installing you can easily launch it from the command line or write a BAT script to execute it for you.
To send date through UDP rather than TCP, use the "-u" switch.
For example, to send the data to UPD port 2345 on localhost execute:
nc -u localhost 2345
Then type the data you want to send.
I was having quite a few problems sending a UDP command to a Brightsign digital sign with netcat. I ended up using Swiss File Knife. It is possible I had the syntex wrong with my netcat statement. (If anyone could suggest the correct syntax based on my working SFK statement, I would love to know)
I just wanted to send a few asci key words to my sign from a batch file.
My sign was 192.168.1.22 and listening on port 5000
Here are my working steps:
Download Swiss File Knife SKF: http://swissfileknife.sourceforge.net/
Copied the file to C:\tools and renamed the sfk174.exe file to skf.exe(to make is shorter) and used the bellow syntax to send the UDP command Special
C:\tools\sfk udpsend 192.168.1.22 5000 “Special” (make sure you put your asci word in quotes. it will work without but not for words with spaces between)
I put the commands in a batch file and created a windows icon for the customer and they worked great.
You can send an udp packet like this :
c:\nemesis\nemesis.exe udp -P do7on.txt -D 192.168.0.10 -y 1025
Nemesis : http://nemesis.sourceforge.net/
I need to create SSH tunnel with PuTTY in Windows, that would do the same as this command in Linux:
ssh -fN -L 2000:SomeIp:2000 myusername#myLinuxBox
I tried many options in PuTTY, including setting source port in GUI to "2000" and destination to "SomeIp:2000". Destination is set to local (as the -L switch suggests).
I successfully login to my SSH box but port forward is not made.
Is this even possible in Windows, so that all the connections made by programs that use this port (2000) will go through this tunnel?
With the PuTTY suite, you can set up a tunnel either using the PuTTY itself (GUI) or using the command-line tool plink.exe.
With the plink.exe, you use the same arguments as with the OpenSSH ssh, except for the -f, which does not have an equivalent in Windows.
plink.exe -N -L 2000:SomeIp:2000 myusername#myLinuxBox
Reference: Using the command-line connection tool Plink
With the PuTTY, the -L 2000:SomeIp:2000 translates to:
So it's actually, what you claim to have tried. If you have any problems, use the PuTTY event log to investigate:
The -N translates to the option "Don't start a shell or command at all".
But it probably does not make sense with a GUI client to enable it, as you get a window anyway, you just cannot do anything with it. See also the PuTTY wish no-terminal-window.
If you are going to use the tunnel to connect with PuTTY to another server, you can actually set up the tunnel as a part of the session settings with use of plink as a proxy, see: PuTTY configuration equivalent to OpenSSH ProxyCommand.
You probably want to use plink.exe instead of the GUI client. The command line syntax is compatible iirc.
Or you can wade through the putty GUI, which also allows this. See Connection > SSH > Tunnels on the left side with the option tree.
The answers above mention two different ways of resolving the problem:
using plink
using putty GUI
I don't have plink and I can't download the plink.exe file (it is a closely monitored restricted environment) so used a different way to script the solution with a one-line script:
start putty -ssh myusername#myLinuxBox -pw my_pw -L 2000:localhost:2000
Store this in a batch file (file extension ".bat", e.g. "tunnel.bat"). So every time you double-click on this file the command is run and putty creates the ssh tunnel. If you want more tunnels just repeat this part
-L 2000:localhost:2000
by changing the ports accordingly.
"Source" port is a port number on the same machine from which you are running putty (eg. open this in your browser: 127.0.0.1:source). "Destination" is your remote port that you want to connect to from your local machine. It started to work after I realized this.