Concatenate and pass as parameter, bash
Clash Royale CLAN TAG#URR8PPP
up vote
2
down vote
favorite
Need to remove default gateway. For example, there is an IP 192.168.4.15 with default gateway 192.168.4.14. I connect to WLAN with gw 10.0.0.1 and after that I would like do remove previous gw.
IFS='.' read -ra IPARR <<< "$IP"
Gateway="$IPARR[0].$IPARR[1].$IPARR[2].14"
ssh blah@$IP '/sbin/route -v del default gw $Gateway;'
#ssh blah@$IP '/sbin/ip route delete $Gateway dev rndis0;'
#ssh blah@$IP '/sbin/route -n'
Both ways don't work. However, it is possible to remove it if I ssh into machine. My guess is that something wrong with passing $Gateway variable. Any suggestions?
bash ssh command-line
add a comment |
up vote
2
down vote
favorite
Need to remove default gateway. For example, there is an IP 192.168.4.15 with default gateway 192.168.4.14. I connect to WLAN with gw 10.0.0.1 and after that I would like do remove previous gw.
IFS='.' read -ra IPARR <<< "$IP"
Gateway="$IPARR[0].$IPARR[1].$IPARR[2].14"
ssh blah@$IP '/sbin/route -v del default gw $Gateway;'
#ssh blah@$IP '/sbin/ip route delete $Gateway dev rndis0;'
#ssh blah@$IP '/sbin/route -n'
Both ways don't work. However, it is possible to remove it if I ssh into machine. My guess is that something wrong with passing $Gateway variable. Any suggestions?
bash ssh command-line
You're using the wrong quotes.''
prevent variable expansion.
– muru
Dec 30 '14 at 10:52
1
@muru, or withssh
it will mean that the variable will get expanded on the remote host rather than locally where theGateway
variable has been set.
– Graeme
Dec 30 '14 at 11:10
@Graeme Indeed.
– muru
Dec 30 '14 at 11:12
Thanks guys, I have been trying to figure out what is wrong for a few hours already.
– mikedanylov
Dec 30 '14 at 11:17
duplicate: stackoverflow.com/q/27703579/7552
– glenn jackman
Dec 30 '14 at 13:54
add a comment |
up vote
2
down vote
favorite
up vote
2
down vote
favorite
Need to remove default gateway. For example, there is an IP 192.168.4.15 with default gateway 192.168.4.14. I connect to WLAN with gw 10.0.0.1 and after that I would like do remove previous gw.
IFS='.' read -ra IPARR <<< "$IP"
Gateway="$IPARR[0].$IPARR[1].$IPARR[2].14"
ssh blah@$IP '/sbin/route -v del default gw $Gateway;'
#ssh blah@$IP '/sbin/ip route delete $Gateway dev rndis0;'
#ssh blah@$IP '/sbin/route -n'
Both ways don't work. However, it is possible to remove it if I ssh into machine. My guess is that something wrong with passing $Gateway variable. Any suggestions?
bash ssh command-line
Need to remove default gateway. For example, there is an IP 192.168.4.15 with default gateway 192.168.4.14. I connect to WLAN with gw 10.0.0.1 and after that I would like do remove previous gw.
IFS='.' read -ra IPARR <<< "$IP"
Gateway="$IPARR[0].$IPARR[1].$IPARR[2].14"
ssh blah@$IP '/sbin/route -v del default gw $Gateway;'
#ssh blah@$IP '/sbin/ip route delete $Gateway dev rndis0;'
#ssh blah@$IP '/sbin/route -n'
Both ways don't work. However, it is possible to remove it if I ssh into machine. My guess is that something wrong with passing $Gateway variable. Any suggestions?
bash ssh command-line
bash ssh command-line
edited Nov 20 at 22:27
Rui F Ribeiro
38.2k1475125
38.2k1475125
asked Dec 30 '14 at 10:48
mikedanylov
1314
1314
You're using the wrong quotes.''
prevent variable expansion.
– muru
Dec 30 '14 at 10:52
1
@muru, or withssh
it will mean that the variable will get expanded on the remote host rather than locally where theGateway
variable has been set.
– Graeme
Dec 30 '14 at 11:10
@Graeme Indeed.
– muru
Dec 30 '14 at 11:12
Thanks guys, I have been trying to figure out what is wrong for a few hours already.
– mikedanylov
Dec 30 '14 at 11:17
duplicate: stackoverflow.com/q/27703579/7552
– glenn jackman
Dec 30 '14 at 13:54
add a comment |
You're using the wrong quotes.''
prevent variable expansion.
– muru
Dec 30 '14 at 10:52
1
@muru, or withssh
it will mean that the variable will get expanded on the remote host rather than locally where theGateway
variable has been set.
– Graeme
Dec 30 '14 at 11:10
@Graeme Indeed.
– muru
Dec 30 '14 at 11:12
Thanks guys, I have been trying to figure out what is wrong for a few hours already.
– mikedanylov
Dec 30 '14 at 11:17
duplicate: stackoverflow.com/q/27703579/7552
– glenn jackman
Dec 30 '14 at 13:54
You're using the wrong quotes.
''
prevent variable expansion.– muru
Dec 30 '14 at 10:52
You're using the wrong quotes.
''
prevent variable expansion.– muru
Dec 30 '14 at 10:52
1
1
@muru, or with
ssh
it will mean that the variable will get expanded on the remote host rather than locally where the Gateway
variable has been set.– Graeme
Dec 30 '14 at 11:10
@muru, or with
ssh
it will mean that the variable will get expanded on the remote host rather than locally where the Gateway
variable has been set.– Graeme
Dec 30 '14 at 11:10
@Graeme Indeed.
– muru
Dec 30 '14 at 11:12
@Graeme Indeed.
– muru
Dec 30 '14 at 11:12
Thanks guys, I have been trying to figure out what is wrong for a few hours already.
– mikedanylov
Dec 30 '14 at 11:17
Thanks guys, I have been trying to figure out what is wrong for a few hours already.
– mikedanylov
Dec 30 '14 at 11:17
duplicate: stackoverflow.com/q/27703579/7552
– glenn jackman
Dec 30 '14 at 13:54
duplicate: stackoverflow.com/q/27703579/7552
– glenn jackman
Dec 30 '14 at 13:54
add a comment |
1 Answer
1
active
oldest
votes
up vote
2
down vote
accepted
So, the answer is to use double quotes when ssh'ing into machine:
ssh blah@$IP "/sbin/route -v del default gw $Gateway;"
You should stop using obsolete commands, and start using ip instead: ssh blah@IP "/sbin/ip route del default via $Gateway"
– MariusMatutiae
Dec 30 '14 at 14:29
@MariusMatutiae, could you explain more what is the difference between route and ip route?
– mikedanylov
Dec 31 '14 at 8:42
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
accepted
So, the answer is to use double quotes when ssh'ing into machine:
ssh blah@$IP "/sbin/route -v del default gw $Gateway;"
You should stop using obsolete commands, and start using ip instead: ssh blah@IP "/sbin/ip route del default via $Gateway"
– MariusMatutiae
Dec 30 '14 at 14:29
@MariusMatutiae, could you explain more what is the difference between route and ip route?
– mikedanylov
Dec 31 '14 at 8:42
add a comment |
up vote
2
down vote
accepted
So, the answer is to use double quotes when ssh'ing into machine:
ssh blah@$IP "/sbin/route -v del default gw $Gateway;"
You should stop using obsolete commands, and start using ip instead: ssh blah@IP "/sbin/ip route del default via $Gateway"
– MariusMatutiae
Dec 30 '14 at 14:29
@MariusMatutiae, could you explain more what is the difference between route and ip route?
– mikedanylov
Dec 31 '14 at 8:42
add a comment |
up vote
2
down vote
accepted
up vote
2
down vote
accepted
So, the answer is to use double quotes when ssh'ing into machine:
ssh blah@$IP "/sbin/route -v del default gw $Gateway;"
So, the answer is to use double quotes when ssh'ing into machine:
ssh blah@$IP "/sbin/route -v del default gw $Gateway;"
answered Dec 30 '14 at 11:27
mikedanylov
1314
1314
You should stop using obsolete commands, and start using ip instead: ssh blah@IP "/sbin/ip route del default via $Gateway"
– MariusMatutiae
Dec 30 '14 at 14:29
@MariusMatutiae, could you explain more what is the difference between route and ip route?
– mikedanylov
Dec 31 '14 at 8:42
add a comment |
You should stop using obsolete commands, and start using ip instead: ssh blah@IP "/sbin/ip route del default via $Gateway"
– MariusMatutiae
Dec 30 '14 at 14:29
@MariusMatutiae, could you explain more what is the difference between route and ip route?
– mikedanylov
Dec 31 '14 at 8:42
You should stop using obsolete commands, and start using ip instead: ssh blah@IP "/sbin/ip route del default via $Gateway"
– MariusMatutiae
Dec 30 '14 at 14:29
You should stop using obsolete commands, and start using ip instead: ssh blah@IP "/sbin/ip route del default via $Gateway"
– MariusMatutiae
Dec 30 '14 at 14:29
@MariusMatutiae, could you explain more what is the difference between route and ip route?
– mikedanylov
Dec 31 '14 at 8:42
@MariusMatutiae, could you explain more what is the difference between route and ip route?
– mikedanylov
Dec 31 '14 at 8:42
add a comment |
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f176573%2fconcatenate-and-pass-as-parameter-bash%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
You're using the wrong quotes.
''
prevent variable expansion.– muru
Dec 30 '14 at 10:52
1
@muru, or with
ssh
it will mean that the variable will get expanded on the remote host rather than locally where theGateway
variable has been set.– Graeme
Dec 30 '14 at 11:10
@Graeme Indeed.
– muru
Dec 30 '14 at 11:12
Thanks guys, I have been trying to figure out what is wrong for a few hours already.
– mikedanylov
Dec 30 '14 at 11:17
duplicate: stackoverflow.com/q/27703579/7552
– glenn jackman
Dec 30 '14 at 13:54