Reply
New Member
Posts: 20
Registered: ‎01-21-2014
Kudos: 6
Solutions: 1
Accepted Solution

script

Hello

I have made a script to disable and enable interface.

 

#!/bin/bash
run=/opt/vyatta/bin/vyatta-op-cmd-wrapper

if ping -c 10 192.168.100.254 &> /dev/null
then
echo "UP"
$run configure
delete interfaces ethernet eth2 disable
commit
else
echo "DOWN"
$run configure
set interfaces ethernet eth2 disable
commit
fi

But It doesn't work

 

Maybe, someone knows how to do it correct? 

 

Best regards


Accepted Solutions
Veteran Member
Posts: 6,594
Registered: ‎03-24-2016
Kudos: 1719
Solutions: 757

Re: script

Try below:   (and add if then logic at will )

 

#!/bin/vbash
WR="/opt/vyatta/sbin/vyatta-cfg-cmd-wrapper"


$WR begin
$WR set interfaces ethernet eth2 disable
$WR commit
$WR end

Also try executing as root

View solution in original post

New Member
Posts: 20
Registered: ‎01-21-2014
Kudos: 6
Solutions: 1

Re: script

#!/bin/bash
WR="/opt/vyatta/sbin/vyatta-cfg-cmd-wrapper"

if ping -c 10 10.33.2.1 &> /dev/null
then
echo "UP"
$WR begin
$WR delete interfaces ethernet eth2 disable
$WR commit
$WR end
else
echo "DOWN"
$WR begin
$WR set interfaces ethernet eth2 disable
$WR commit
$WR end
fi

It works!

 

Thak you very much! Man Wink

 

View solution in original post


All Replies
Established Member
Posts: 1,548
Registered: ‎05-03-2016
Kudos: 540
Solutions: 151

Re: script

Try vbash instead of bash.

Put $run in front of all config commands set, delete, commit.

May want exit after commit but cannot remember for sure.
New Member
Posts: 20
Registered: ‎01-21-2014
Kudos: 6
Solutions: 1

Re: script

I have tried but still it doesn't work Man Sad 

Veteran Member
Posts: 6,594
Registered: ‎03-24-2016
Kudos: 1719
Solutions: 757

Re: script

Try below:   (and add if then logic at will )

 

#!/bin/vbash
WR="/opt/vyatta/sbin/vyatta-cfg-cmd-wrapper"


$WR begin
$WR set interfaces ethernet eth2 disable
$WR commit
$WR end

Also try executing as root

New Member
Posts: 20
Registered: ‎01-21-2014
Kudos: 6
Solutions: 1

Re: script

#!/bin/bash
WR="/opt/vyatta/sbin/vyatta-cfg-cmd-wrapper"

if ping -c 10 10.33.2.1 &> /dev/null
then
echo "UP"
$WR begin
$WR delete interfaces ethernet eth2 disable
$WR commit
$WR end
else
echo "DOWN"
$WR begin
$WR set interfaces ethernet eth2 disable
$WR commit
$WR end
fi

It works!

 

Thak you very much! Man Wink

 

Reply