Is there a way to automate serial port connection and collect output to a file from some commands?
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
11-22-2016 01:56 AM
Using a Linux bash script, is there a way to log into an Extreme switch through the com port, run a command and collect the output to a file where the bash script was executed from? I need to automate collecting some data from around 100 switches that are not connected to a network where I can use ssh. I need to access them physically using the serial console only.
Manually it would be something like:
screen /dev/ttyUSB0 9600
admin
show version
exit
where I would then dump the version information to a file.
Manually it would be something like:
screen /dev/ttyUSB0 9600
admin
show version
exit
where I would then dump the version information to a file.
6 REPLIES 6
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
11-24-2016 04:18 AM
You were both right; I had better luck with cu. It’s not perfect, but it will work. In order to parse the redirected file, I had to:
- Use sed to remove a line that that always contained a non-ascii string
- Use sed to do some find and replaces to clean up a couple lines that I need to parse and couldn't just delete.
- I am also using dos2unix on the file before I parse it. This might not be needed now, but it was helping when I was using screen, so I left that in.
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
11-23-2016 09:42 AM
Hi Ryan,
That could be a result of screen trying to control the terminal. Screen is terminal oriented and controls the output visible on the terminal, including scrolling the currently displayed up one line to display the next line. That does not work well together with expect.
A line oriented program like cu (Debian/Ubuntu package cu) might work better with expect, but I haven't used it for many years.
I am using expect together with SSH or telnet (in a lab) to a console server connecting the switch consoles and cannot test with a direct serial connection at this time.
Hope to help,
Erik
That could be a result of screen trying to control the terminal. Screen is terminal oriented and controls the output visible on the terminal, including scrolling the currently displayed up one line to display the next line. That does not work well together with expect.
A line oriented program like cu (Debian/Ubuntu package cu) might work better with expect, but I haven't used it for many years.
I am using expect together with SSH or telnet (in a lab) to a console server connecting the switch consoles and cannot test with a direct serial connection at this time.
Hope to help,
Erik
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
11-23-2016 06:34 AM
Hi Ryan,
the non-ASCII characters are terminal control codes, used e.g. by the pager. If you are gathering output automatically, you should issue the command "disable clipaging" before your show commands.
Erik
the non-ASCII characters are terminal control codes, used e.g. by the pager. If you are gathering output automatically, you should issue the command "disable clipaging" before your show commands.
Erik
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
11-23-2016 01:19 AM
Konstantin,
Thanks for the detailed response! This works to create a file, but the file also including what non-ascii characters like: [!p [?3;4l [4l > [?1049
I also added the command: show port 1-48 information detail | include "Port:|Link State"
This stops outputting at around 32 ports.
Thanks for the detailed response! This works to create a file, but the file also including what non-ascii characters like: [!p [?3;4l [4l > [?1049
I also added the command: show port 1-48 information detail | include "Port:|Link State"
This stops outputting at around 32 ports.
