On an X450a-48t is there a way to put more than one command on the command line ? e.g. in UNIX commands can be separated by a semi-colon

  • 0
  • 1
  • Question
  • Updated 3 years ago
  • Answered
On an X450a-48t is there a way to put more than one command on the command line ? For example in UNIX commands can be separated by a semi-colon
Photo of John Nicolson

John Nicolson

  • 90 Points 75 badge 2x thumb

Posted 3 years ago

  • 0
  • 1
Photo of Paul Russo

Paul Russo, Alum

  • 9,694 Points 5k badge 2x thumb
Hey John

No you can't put more than one command in at a time but what I normally do is type the commands in notepad or something and then just copy and paste them into the CLI.  Doing that allows for you to enter any amount of commands at one time.

Thanks
P
Photo of PARTHIBAN CHINNAYA

PARTHIBAN CHINNAYA, Alum

  • 4,362 Points 4k badge 2x thumb
I would like to understand the question again.
The reason I would want such a feature is to do things faster.

EXOS has better options.
It supports CLI scripting.

enable cli-scripting 
Sample cli scripts

The following script displays the date and time:set var CLI.OUT " "
show switch
set var date $TCL(lrange ${CLI.OUT} 27 29)
set var year $TCL(lrange ${CLI.OUT} 31 31)
set var date $TCL(linsert $date 3 $year)
set var time $TCL(lrange ${CLI.OUT} 30 30)
show var date
show var time
The following script sorts the FDB table in descending order:
set var CLI.OUT " "
show fdb
set var x1 $TCL(split ${CLI.OUT} "\n")
set var x2 $TCL(lsort -decreasing $x1)
set var output $TCL(join $x2 "\n")
show var output
The following script extracts the MAC address given the age of an FDB entry:
set var CLI.OUT " "
show fdb
set var input $TCL(split ${CLI.OUT} "\n")
set var y1 $TCL(lsearch -glob $input *age*)
set var y2 $TCL(lindex $input $y1)
set var y3 $TCL(split $y2 " ")
set var y4 $TCL(lindex $y3 0)
show var y4
Photo of John Nicolson

John Nicolson

  • 90 Points 75 badge 2x thumb
I want to run an automated script from a UNIX platform that connects to an X450 (using UNIX Expect TCL),  enters the password, then runs command(s)  and exits the X450 once the prompt re-appears. It's fairly straightforward to get this to happen for a simple comand like 'show slot'. But a command like 'show ipstats' requires 'disable clipaging' or it will stop at the 'Press SPACE to continue' prompt. If I was doing this sort of thing to another UNIX server I would simply send "disable clipaging ; show ipstats" or indeed any set of commands serperated by a semi-colon.
Photo of Grosjean, Stephane

Grosjean, Stephane, Employee

  • 12,552 Points 10k badge 2x thumb
I can't test right now, but would inserting a \n between commands would work? Worth the try.
Photo of PARTHIBAN CHINNAYA

PARTHIBAN CHINNAYA, Alum

  • 4,362 Points 4k badge 2x thumb
Below is a perl script which I used to modify for all networking devices.
You just need to have similar commands in TCL and it will work

use Net::Telnet;$telnet = new Net::Telnet ( Timeout=>10,Errmode=>'die');
$telnet->open('10.209.70.x');
$telnet->login('admin', 'admin');
print $telnet->cmd('configure');
print $telnet->cmd('run show version');
sleep 1;
print $telnet->cmd('run show interfaces ge-0/0/0 brief | grep Physical ');
sleep 1;
print $telnet->cmd('exit');
print $telnet->cmd('set cli screen-length 0'); ------------Instead say disable clipaging
print $telnet->cmd('configure');
print $telnet->cmd(' run show log messages | grep ge-0/0/0 | last 10 ');#this works now
sleep 10;
$counter = 0;
while ($counter < 3)
{
chomp ();
open (FILE, ">gilly.txt");
print FILE (print $telnet->cmd(' run show spanning-tree interface '));
sleep .5;
close (FILE);
$counter = $counter + 1;
}
(Edited)
Photo of rbrt_weiler

rbrt_weiler

  • 834 Points 500 badge 2x thumb
Actually, I do have a use case where having multiple commands in one line would be extremely useful: Changing IP addresses. Doing a
unconfigure vlan OldMgmtVLAN ipaddress ; configure vlan NewMgmtVLAN ipaddress <oldipaddress>
would be faster and easier than writing a script to do this. Yes, it's just a matter of convenience, but hey...
Photo of Grosjean, Stephane

Grosjean, Stephane, Employee

  • 12,552 Points 10k badge 2x thumb
Maybe my comment to John's post is a bit hidden.

I can't test right now, but would inserting a \n between commands would work? Worth the try.
Photo of John Nicolson

John Nicolson

  • 90 Points 75 badge 2x thumb

Hi All, many thanks for all of your replies. I have used the Unix Expect TCL Script to resolve my issue but I found the only way I could get the Expect script to interact with the ExtremeOS was to 'send' all of the commands I want to run in one command line separated by '\n'. For example, for those familiar with Expect TCL scripting, this is the line I use "send -- "disable clipaging\nshow l2stats\nshow ipstats\nshow port statistics no-refresh\n\n"". So the solution I found is a combination of your suggestions. Thanks again for your replies.

Photo of PARTHIBAN CHINNAYA

PARTHIBAN CHINNAYA, Alum

  • 4,362 Points 4k badge 2x thumb
Nice to hear that you fixed it.
If you can paste the script here it will help many people looking for similar solution.