Script to send serial commands over ethernet


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Script to send serial commands over ethernet
# 1  
Old 07-23-2013
Error Script to send serial commands over ethernet

Hi there,

I have a Debian server (192.168.1.1) connected through ethernet to a RS232 device servers (192.168.1.5) that is then connected through RS232 to a Video Projector.

The idea is that I want to send commands to the video projector (eg. turn on/off) via the device server.

According to the Benq Video Projector Manual, the command to read the power status is :
Code:
<CR>*pow=?#<CR>

The Moxa NPort 5150 Manual tells me to use port 4001 for communication.

All right then...

How do I send my command?

I tried
Code:
root@arcturus:~# telnet 192.168.1.5 4001
Trying 192.168.1.5...
telnet: Unable to connect to remote host: Connection refused
root@arcturus:~# echo -e '\r*pow=?#\r' | netcat 192.168.1.5 4001
(UNKNOWN) [192.168.1.5] 4001 (?) : Connection refused

Do you have any idea on how I should do that?

== edit start =========================
I found out that if I use UDP mode, the connection is accepted but freezes.
I have to press Ctrl+C to return to tty:
Code:
root@arcturus:~# echo -en '\r*pow=?#\r' | netcat -n -v -u -o /tmp/hextraffic.dump 192.168.1.5 4001
(UNKNOWN) [192.168.1.5] 4001 (?) open
^C sent 9, rcvd 0

== edit end ===========================



Regards
Santiago

Last edited by chebarbudo; 07-23-2013 at 01:54 PM..
# 2  
Old 07-23-2013
If telnet doesn't work netcat isn't going to work...

Check your firewall, maybe it is blocking connecting to unknown ports like that.

Verify the device's IP address and port. It may not be at default.
# 3  
Old 07-23-2013
Hi Corona688,

As I just edited my post, I got netcat to work using udp mode.
How do I set UDP mode with telnet?

No firewall at all.
The IP address is correct, I set it up myself connecting to the Moxa Server using telnet (with no port):

Code:
santiago@arcturus:~$ telnet 192.168.1.5
Trying 192.168.1.5...
Connected to 192.168.1.5.
Escape character is '^]'.


-----------------------------------------------------------------------------
Model name       : NPort 5150
MAC address      : 00:90:E8:2B:3B:63
Serial No.       : 4901
Firmware version : 3.3 Build 08061714
System uptime    : 35 days, 03h:50m:45s
-----------------------------------------------------------------------------
<< Main menu >>
  (1) Basic settings
  (2) Network settings
  (3) Serial settings
  (4) Operating settings
  (5) Accessible IP settings
  (6) Auto warning settings
  (7) Monitor
  (8) Ping
  (9) Change password
  (a) Load factory default
  (v) View settings
  (s) Save/Restart
  (q) Quit

Key in your selection: 2
-----------------------------------------------------------------------------
<< Main menu->Network settings >>
  (1) IP address
  (2) Netmask
  (3) Gateway
  (4) IP configuration
  (5) DNS server 1
  (6) DNS server 2
  (7) SNMP
  (8) SNMP community name
  (9) SNMP contact
  (a) SNMP location
  (b) Auto IP report to IP
  (c) Auto IP report to UDP port
  (d) Auto IP report period
  (v) View settings
  (m) Back to main menu
  (q) Quit

Key in your selection: 1
IP address: 192.168.1.5
Set IP address success

Press any key to continue...


Last edited by chebarbudo; 07-23-2013 at 02:03 PM..
# 4  
Old 07-23-2013
UDP cannot 'accept' connections. It simply has no way to tell that it's failing, it happily throws messages into a black hole.

The device obviously expects TCP if you're supposed to use telnet.

You have verified the IP address, can you verify the port too?

Last edited by Corona688; 07-23-2013 at 02:27 PM..
# 5  
Old 07-23-2013
Don't overlook networking capabilities of bash and other shells, as well as gawk - it is very simple to send a string to a port on a host.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Communicating with ethernet to serial LED sign - is this feasible?

I have a london-electronics LED sign I picked up on eBay which I would like to display custom messages on programmatically. It is working ok. Opening it up, it has an ethernet to serial connection currently plugged in and a serial connection currently unplugged internally (same connectors).... (9 Replies)
Discussion started by: windswept321
9 Replies

2. UNIX for Dummies Questions & Answers

How to Send AT Commands to mgetty?

Hello All, I've been working on something which requires a dialup USB Modem. I have been using minicom with success entering "AT Commands" directly into the terminal window that shows after running the minicom command. I had already configured the modem through minicom and was able to... (2 Replies)
Discussion started by: mrm5102
2 Replies

3. Shell Programming and Scripting

Send/receive file through serial using minicom

i have connected with my board through serial interface using minicom and i am running a bash script, which should test ethernet (ping test), USB read/write, RS232 .. I have managed to test ethernet and USB read/write. I test ethernet with ping. I test USB read/write, using dd and verifying... (10 Replies)
Discussion started by: linuxmember
10 Replies

4. Programming

unable to send read and write serial port

hey frns pls help me out !! i hav a code of c that i have to include in my project. i am using a device (geomeda) that has unix based OS. it also support SIM card for connecting to server . I need to send SMS to user from this device.. below code is not working .. i am unable to send sms and the... (7 Replies)
Discussion started by: yashwantkumar
7 Replies

5. Linux

send remote commands to windows machine?

hey guys, I've done some searching and other than winexe I haven't been able to find a way to send remote commands to a windows machine. The problem I get is with winexe whenever you send the process to the background in a script, I get the following error. :wall: Any help is appreciated! ... (0 Replies)
Discussion started by: terrell
0 Replies

6. IP Networking

Need a bridge from an ethernet interface to a serial interface

This is my situation DOS pc serial cable (sl0) Linux Pc eth1 192.168.0.10 <-------------------->192.168.0.2 <------------>192.168.0.1 (router) I connected the linux pc and the dos pc with a SLIP (serial line internet protocol), so they can communicate in the sl0 interface. ... (3 Replies)
Discussion started by: mghis
3 Replies

7. Cybersecurity

Logging shell commands and send it out

Dear friends I'm looking for a solution to log all commands that users do in my RedHat box, and send it out to other remote server, Is there any guide for that Thanks ---------- Post updated at 04:20 AM ---------- Previous update was at 03:47 AM ---------- I can think of something else I... (7 Replies)
Discussion started by: reaky
7 Replies

8. Shell Programming and Scripting

Make ssh and send commands

Hi, I'm trying to make an SSH into a SGSN node and collect some commands printouts.:confused: I really don't know how this can be done. I think it must be like this: #!/bin/bash ssh user@192.168.88.10 Then I must enter the password, but I don't know how to do it, I tried with: echo... (3 Replies)
Discussion started by: nagomes
3 Replies

9. Shell Programming and Scripting

How to send AT commands after getting into Kermit window?

We're using Kermit 8.0.209 in Linux environment. We're trying to invoke kermit from an application, send some AT commands and receive the responses from the End terminals like mobiles/modems. We access these deivces through serial ports. For eg., to send a file we use command-line options like... (4 Replies)
Discussion started by: pratiul
4 Replies

10. Shell Programming and Scripting

HELP: Need to send commands to Program

Hi, I am an absolute beginner in Unix and I need to send a commands to a program I have created a script that will let me login to the program, however, i cannot get the script to send commands to this program. When the cript logs into the program, the display/ prompt is as follows: 1>... (1 Reply)
Discussion started by: the_m4ch1ne
1 Replies
Login or Register to Ask a Question