echo !SR | nc 255.255.2.2 80 - how to in XP?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting echo !SR | nc 255.255.2.2 80 - how to in XP?
# 1  
Old 01-16-2011
echo !SR | nc 255.255.2.2 80 - how to in XP?

Hi guys I am trying to interface with an old industrial scanner through an old PC with an old network card and a copy of Linux.

It now needs to speak to a Windows XP machine, but I have no idea what the Windows equivalent of these functions would are:
Code:
echo !1 | nc 255.255.2.2 80
echo ?2 | nc 255.255.2.2 80 > list1.txt
echo ?3 | nc 255.255.2.2 80 > list2.txt
echo !4 | nc 255.255.2.2 80

Any help anyone can do to help me translate these actions would be very much appreciated.

Big thanks

Tony

Last edited by Scott; 01-16-2011 at 11:43 AM.. Reason: Code tags
# 2  
Old 01-16-2011
I can't speak about whatever's in the rest of your script, but all four of those lines should run properly in windows CMD and/or a batch file as long as you have an nc.exe available in the current directory or somewhere in your PATH (and your network settings allow you to talk to that odd address!)

I think that "nc" must be netcat. It's a pretty common tool that just connects a TCP socket on the given port and address, writes what it's told to write, and prints whatever it gets back to terminal. (or file, when redirected like >filename). This script appears to be connecting to the device on port 80(the standard HTTP port), sending two-character commands, and sometimes saving the result it gets back from it into a txt file.

Netcat has windows ports available in many places.
# 3  
Old 01-16-2011
Sincerest thanks Corona.

Excuse my ignorance, but is the echo important?

i.e. would
nc 255.255.2.2 80 work just as well

or is the echo an important part of the process?

Also, another section of the code uses the function stripcat e.g.
./stripcat union.txt
anyone know of this function? My preliminary search on google has proved unsuccessful.

Again - many thanks in advance.

Tony.

Last edited by TonyG; 01-16-2011 at 01:35 PM..
# 4  
Old 01-16-2011
Quote:
Originally Posted by TonyG
Sincerest thanks Corona.

Excuse my ignorance, but is the echo important?

i.e. would
nc 255.255.2.2 80 work just as well
Here's a basic intro to shell scripting, then. "echo", even in windows CMD, just prints what you tell it to.

Code:
c:> echo !1
!1
c:>

The netcat command reads from the terminal, that is, sends what you type into it.

Or, it can read from another program, which is what | is for. echo !1 | nc 255.255.2.2 80 prints !1 and netcat reads it, sends it over the network socket, and prints what it gets back to the terminal.

So yes, the echo is necessary, it's two commands used in concert. If you didn't feed something into it, netcat would just sit there waiting for you to type...
Quote:
Also, another section of the code uses the function stripcat e.g.
./stripcat union.txt
anyone know of this function? My preliminary search on google has proved unsuccessful.
It's being run from the current directory, which suggests it's a custom program made for this application. Hopefully another shell script. Its name suggests it's a filter of some sort but what it actually does I can't guess, if you could post its contents that'd help a lot.

Last edited by Corona688; 01-16-2011 at 07:05 PM..
Login or Register to Ask a Question

Previous Thread | Next Thread

6 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Spliting a line after 255 characters.

Hi Guys, I have a file which contains multiple lines. I need to split each line 255 characters and then I need to add call statement in the front and semi colon at the end. I/P: call sp_rebuildindex('aaa.aaa','column column column column column column column column column column ... (4 Replies)
Discussion started by: Booo
4 Replies

2. UNIX for Dummies Questions & Answers

Exit Status 255, Connection closed in SFTP

I'm trying to connect from Server A to Server B to transfer files from A to B. I'm using NUID A1 in Server A and NUID A2 in Server B. I have done the following the steps to setup password-less login. 1. Add the public key of A1 in A to the Authorized keys of A2 in B. 2. Add the public key of... (4 Replies)
Discussion started by: sanchid312
4 Replies

3. Shell Programming and Scripting

sed 255 Character Limitation

Hello, I am using sed command to place a comma dynamically in certain positions. When the position variable exceeds 255 characters, it errors out. I would appreciate if someone can point in the correct direction sed 's/^\(.\{'"$pos"'\}\)./\1,/' ragha.txt > ragha3.txt If $pos > 255,... (8 Replies)
Discussion started by: ragha81
8 Replies

4. Shell Programming and Scripting

sed limitation of 255 characters

Gurus, sed -e "s/\(.\{1,255\}\)\(.\{1,2\}\)\(.*\)/\1AB\3/" FILE ---this works sed -e "s/\(.\{1,468\}\)\(.\{1,2\}\)\(.*\)/\1AB\3/" FILE ---this does not It works only till 1,255 ( any number below 255 works) Any one know how to increase this limit. Thanks Sirababu (4 Replies)
Discussion started by: sirababu
4 Replies

5. Solaris

Exit status 255 on sftp

HI guys When i try SFTP to a machine using a user account whose entry in /etc/passwd as follows user:x:8005:508::/export/home/user:/bin/false and i am not placed my keys over there i am using the password option in the sftp Since the keys are not there it ask for the password ... (5 Replies)
Discussion started by: GIC1986
5 Replies

6. Programming

make[1] *** [libsupp.a] Error 255

I have searched google and these forums as well. I am trying to compile proftpd on a vanilla Solaris 10 server and I am getting an error when I try to 'make' Server - Solaris 10 update 4 Installed packages from sunfreeware.com autoconf-2.60-sol10-sparc-local... (2 Replies)
Discussion started by: jjsoladmin
2 Replies
Login or Register to Ask a Question