Bash script to run command in localized CLI [closed]
Clash Royale CLAN TAG#URR8PPP
up vote
-3
down vote
favorite
I'm trying to run a command that access a local switch CLI and runs a simple 'show config'. The script logs in, but then does nothing. I suspect it's because once logged in to the sub-terminal, the commands can't be interpreted. Any ideas?
$a1 = "show config"
exec cli
sleep 2
exec $a1
exec exit
bash
closed as unclear what you're asking by jasonwryan, G-Man, cas, ilkkachu, GAD3R Feb 1 at 18:27
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, itâÂÂs hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
add a comment |Â
up vote
-3
down vote
favorite
I'm trying to run a command that access a local switch CLI and runs a simple 'show config'. The script logs in, but then does nothing. I suspect it's because once logged in to the sub-terminal, the commands can't be interpreted. Any ideas?
$a1 = "show config"
exec cli
sleep 2
exec $a1
exec exit
bash
closed as unclear what you're asking by jasonwryan, G-Man, cas, ilkkachu, GAD3R Feb 1 at 18:27
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, itâÂÂs hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
1
Could you clarify "that access a local switch CLI"? is it about a network switch? Do you use ssh somewhere?
â Volker Siegel
Feb 1 at 5:06
add a comment |Â
up vote
-3
down vote
favorite
up vote
-3
down vote
favorite
I'm trying to run a command that access a local switch CLI and runs a simple 'show config'. The script logs in, but then does nothing. I suspect it's because once logged in to the sub-terminal, the commands can't be interpreted. Any ideas?
$a1 = "show config"
exec cli
sleep 2
exec $a1
exec exit
bash
I'm trying to run a command that access a local switch CLI and runs a simple 'show config'. The script logs in, but then does nothing. I suspect it's because once logged in to the sub-terminal, the commands can't be interpreted. Any ideas?
$a1 = "show config"
exec cli
sleep 2
exec $a1
exec exit
bash
edited Feb 1 at 4:55
Hunter.S.Thompson
4,50631334
4,50631334
asked Feb 1 at 4:54
K Enz
1
1
closed as unclear what you're asking by jasonwryan, G-Man, cas, ilkkachu, GAD3R Feb 1 at 18:27
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, itâÂÂs hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
closed as unclear what you're asking by jasonwryan, G-Man, cas, ilkkachu, GAD3R Feb 1 at 18:27
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, itâÂÂs hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
1
Could you clarify "that access a local switch CLI"? is it about a network switch? Do you use ssh somewhere?
â Volker Siegel
Feb 1 at 5:06
add a comment |Â
1
Could you clarify "that access a local switch CLI"? is it about a network switch? Do you use ssh somewhere?
â Volker Siegel
Feb 1 at 5:06
1
1
Could you clarify "that access a local switch CLI"? is it about a network switch? Do you use ssh somewhere?
â Volker Siegel
Feb 1 at 5:06
Could you clarify "that access a local switch CLI"? is it about a network switch? Do you use ssh somewhere?
â Volker Siegel
Feb 1 at 5:06
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
1
down vote
After exec cli
, your shell script does not return to run the next line, sleep 2
To be exact, it no longer exists, because exec
replaces the shell process by the new cli
process.
I suspect you do not really want the effect of exec
, and should remove it.
I am not really sure what you want to do, but assuming you want to run the command show config
in cli
, try just writing the command to it's input:
printf "show config" | cli
For similar, but really difficult cases, see expect
Expect did the trick. Thanks!
â K Enz
Feb 1 at 6:06
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
After exec cli
, your shell script does not return to run the next line, sleep 2
To be exact, it no longer exists, because exec
replaces the shell process by the new cli
process.
I suspect you do not really want the effect of exec
, and should remove it.
I am not really sure what you want to do, but assuming you want to run the command show config
in cli
, try just writing the command to it's input:
printf "show config" | cli
For similar, but really difficult cases, see expect
Expect did the trick. Thanks!
â K Enz
Feb 1 at 6:06
add a comment |Â
up vote
1
down vote
After exec cli
, your shell script does not return to run the next line, sleep 2
To be exact, it no longer exists, because exec
replaces the shell process by the new cli
process.
I suspect you do not really want the effect of exec
, and should remove it.
I am not really sure what you want to do, but assuming you want to run the command show config
in cli
, try just writing the command to it's input:
printf "show config" | cli
For similar, but really difficult cases, see expect
Expect did the trick. Thanks!
â K Enz
Feb 1 at 6:06
add a comment |Â
up vote
1
down vote
up vote
1
down vote
After exec cli
, your shell script does not return to run the next line, sleep 2
To be exact, it no longer exists, because exec
replaces the shell process by the new cli
process.
I suspect you do not really want the effect of exec
, and should remove it.
I am not really sure what you want to do, but assuming you want to run the command show config
in cli
, try just writing the command to it's input:
printf "show config" | cli
For similar, but really difficult cases, see expect
After exec cli
, your shell script does not return to run the next line, sleep 2
To be exact, it no longer exists, because exec
replaces the shell process by the new cli
process.
I suspect you do not really want the effect of exec
, and should remove it.
I am not really sure what you want to do, but assuming you want to run the command show config
in cli
, try just writing the command to it's input:
printf "show config" | cli
For similar, but really difficult cases, see expect
edited Feb 1 at 5:05
answered Feb 1 at 4:59
Volker Siegel
10.2k33058
10.2k33058
Expect did the trick. Thanks!
â K Enz
Feb 1 at 6:06
add a comment |Â
Expect did the trick. Thanks!
â K Enz
Feb 1 at 6:06
Expect did the trick. Thanks!
â K Enz
Feb 1 at 6:06
Expect did the trick. Thanks!
â K Enz
Feb 1 at 6:06
add a comment |Â
1
Could you clarify "that access a local switch CLI"? is it about a network switch? Do you use ssh somewhere?
â Volker Siegel
Feb 1 at 5:06