How do I spawn a BASH command in expect?
Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
I have an expect script, and want to spawn a BASH command for it to provide input to. When I use the following syntax:
spawn /bin/bash docker run -v $OVPN_DATA:/etc/openvpn --rm -it kylemanna/openvpn ovpn_initpki`
or:
spawn docker run -v $OVPN_DATA:/etc/openvpn --rm -it kylemanna/openvpn ovpn_initpki
I get the following error:
bad flag "-it": must be -glob, -regexp, -exact, -notransfer, -nocase, -i, -
indices, -iread, -timestamp, -timeout, -nobrace, or --
while executing
"expect {
spawn (/bin/bash) docker run -v $OVPN_DATA:/etc/openvpn --rm -it kylemanna/openvpn
ovpn_initpki
"Enter PEM pass phrase:" {send "DefPEMVPNPassPhra..."
(file "addcontainer.exp" line 7)
How do I tell expect to spawn a BASH command?
bash shell-script expect
add a comment |Â
up vote
0
down vote
favorite
I have an expect script, and want to spawn a BASH command for it to provide input to. When I use the following syntax:
spawn /bin/bash docker run -v $OVPN_DATA:/etc/openvpn --rm -it kylemanna/openvpn ovpn_initpki`
or:
spawn docker run -v $OVPN_DATA:/etc/openvpn --rm -it kylemanna/openvpn ovpn_initpki
I get the following error:
bad flag "-it": must be -glob, -regexp, -exact, -notransfer, -nocase, -i, -
indices, -iread, -timestamp, -timeout, -nobrace, or --
while executing
"expect {
spawn (/bin/bash) docker run -v $OVPN_DATA:/etc/openvpn --rm -it kylemanna/openvpn
ovpn_initpki
"Enter PEM pass phrase:" {send "DefPEMVPNPassPhra..."
(file "addcontainer.exp" line 7)
How do I tell expect to spawn a BASH command?
bash shell-script expect
2
Don't put thespawn
command insideexpect
, do what I suggested in your previous question
â glenn jackman
Feb 7 at 17:31
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I have an expect script, and want to spawn a BASH command for it to provide input to. When I use the following syntax:
spawn /bin/bash docker run -v $OVPN_DATA:/etc/openvpn --rm -it kylemanna/openvpn ovpn_initpki`
or:
spawn docker run -v $OVPN_DATA:/etc/openvpn --rm -it kylemanna/openvpn ovpn_initpki
I get the following error:
bad flag "-it": must be -glob, -regexp, -exact, -notransfer, -nocase, -i, -
indices, -iread, -timestamp, -timeout, -nobrace, or --
while executing
"expect {
spawn (/bin/bash) docker run -v $OVPN_DATA:/etc/openvpn --rm -it kylemanna/openvpn
ovpn_initpki
"Enter PEM pass phrase:" {send "DefPEMVPNPassPhra..."
(file "addcontainer.exp" line 7)
How do I tell expect to spawn a BASH command?
bash shell-script expect
I have an expect script, and want to spawn a BASH command for it to provide input to. When I use the following syntax:
spawn /bin/bash docker run -v $OVPN_DATA:/etc/openvpn --rm -it kylemanna/openvpn ovpn_initpki`
or:
spawn docker run -v $OVPN_DATA:/etc/openvpn --rm -it kylemanna/openvpn ovpn_initpki
I get the following error:
bad flag "-it": must be -glob, -regexp, -exact, -notransfer, -nocase, -i, -
indices, -iread, -timestamp, -timeout, -nobrace, or --
while executing
"expect {
spawn (/bin/bash) docker run -v $OVPN_DATA:/etc/openvpn --rm -it kylemanna/openvpn
ovpn_initpki
"Enter PEM pass phrase:" {send "DefPEMVPNPassPhra..."
(file "addcontainer.exp" line 7)
How do I tell expect to spawn a BASH command?
bash shell-script expect
asked Feb 7 at 16:39
William Edwards
3211420
3211420
2
Don't put thespawn
command insideexpect
, do what I suggested in your previous question
â glenn jackman
Feb 7 at 17:31
add a comment |Â
2
Don't put thespawn
command insideexpect
, do what I suggested in your previous question
â glenn jackman
Feb 7 at 17:31
2
2
Don't put the
spawn
command inside expect
, do what I suggested in your previous questionâ glenn jackman
Feb 7 at 17:31
Don't put the
spawn
command inside expect
, do what I suggested in your previous questionâ glenn jackman
Feb 7 at 17:31
add a comment |Â
2 Answers
2
active
oldest
votes
up vote
0
down vote
The output suggests that spawn
doesn't stop interpreting flags when it encounters a command name.
A common convention is to use --
as a separator between options for a command (which it should parse and interpret), and arguments to things it needs to call (which it should ignore and pass on).
The spawn
output lists --
as one of the possible options, which suggests that it follows that convention. Try specifying it?
spawn /bin/bash -- -c "docker run ..."
the--
probably shouldn't be placed afterbash
and beforebash
flags ...
â thrig
Feb 7 at 17:56
add a comment |Â
up vote
0
down vote
try:
spawn /bin/bash
send "docker run -v $OVPN_DATA:/etc/openvpn --rm -it kylemanna/openvpn ovpn_initpki"
You will need to escape the$
as tcl will expand this within""
. Or you can replace the double quotes byquotes.
â meuh
Feb 7 at 16:51
It's also possible that the quoting can be dropped, and just the -c will be enough to load up bash. Or maybe just quote "docker", though that may not take care of how tcl will handle the variable definitions within the expect file.
â John
Feb 7 at 16:53
bad flag "-c": must be -glob, -regexp, -exact, -notransfer, -nocase, -i, -indices, -iread, -timestamp, -timeout, -nobrace, or --
â William Edwards
Feb 7 at 17:20
The error that you are reporting is from expect. I updated my answer
â John
Feb 7 at 17:52
@JohnW.Gill Not sure what's going on. No errors when I use that code but the container shows many errors saying that the configuration files don't exist (that are created with that input). I'll investigate further.
â William Edwards
Feb 7 at 19:30
 |Â
show 1 more comment
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
The output suggests that spawn
doesn't stop interpreting flags when it encounters a command name.
A common convention is to use --
as a separator between options for a command (which it should parse and interpret), and arguments to things it needs to call (which it should ignore and pass on).
The spawn
output lists --
as one of the possible options, which suggests that it follows that convention. Try specifying it?
spawn /bin/bash -- -c "docker run ..."
the--
probably shouldn't be placed afterbash
and beforebash
flags ...
â thrig
Feb 7 at 17:56
add a comment |Â
up vote
0
down vote
The output suggests that spawn
doesn't stop interpreting flags when it encounters a command name.
A common convention is to use --
as a separator between options for a command (which it should parse and interpret), and arguments to things it needs to call (which it should ignore and pass on).
The spawn
output lists --
as one of the possible options, which suggests that it follows that convention. Try specifying it?
spawn /bin/bash -- -c "docker run ..."
the--
probably shouldn't be placed afterbash
and beforebash
flags ...
â thrig
Feb 7 at 17:56
add a comment |Â
up vote
0
down vote
up vote
0
down vote
The output suggests that spawn
doesn't stop interpreting flags when it encounters a command name.
A common convention is to use --
as a separator between options for a command (which it should parse and interpret), and arguments to things it needs to call (which it should ignore and pass on).
The spawn
output lists --
as one of the possible options, which suggests that it follows that convention. Try specifying it?
spawn /bin/bash -- -c "docker run ..."
The output suggests that spawn
doesn't stop interpreting flags when it encounters a command name.
A common convention is to use --
as a separator between options for a command (which it should parse and interpret), and arguments to things it needs to call (which it should ignore and pass on).
The spawn
output lists --
as one of the possible options, which suggests that it follows that convention. Try specifying it?
spawn /bin/bash -- -c "docker run ..."
answered Feb 7 at 17:48
Wouter Verhelst
7,156831
7,156831
the--
probably shouldn't be placed afterbash
and beforebash
flags ...
â thrig
Feb 7 at 17:56
add a comment |Â
the--
probably shouldn't be placed afterbash
and beforebash
flags ...
â thrig
Feb 7 at 17:56
the
--
probably shouldn't be placed after bash
and before bash
flags ...â thrig
Feb 7 at 17:56
the
--
probably shouldn't be placed after bash
and before bash
flags ...â thrig
Feb 7 at 17:56
add a comment |Â
up vote
0
down vote
try:
spawn /bin/bash
send "docker run -v $OVPN_DATA:/etc/openvpn --rm -it kylemanna/openvpn ovpn_initpki"
You will need to escape the$
as tcl will expand this within""
. Or you can replace the double quotes byquotes.
â meuh
Feb 7 at 16:51
It's also possible that the quoting can be dropped, and just the -c will be enough to load up bash. Or maybe just quote "docker", though that may not take care of how tcl will handle the variable definitions within the expect file.
â John
Feb 7 at 16:53
bad flag "-c": must be -glob, -regexp, -exact, -notransfer, -nocase, -i, -indices, -iread, -timestamp, -timeout, -nobrace, or --
â William Edwards
Feb 7 at 17:20
The error that you are reporting is from expect. I updated my answer
â John
Feb 7 at 17:52
@JohnW.Gill Not sure what's going on. No errors when I use that code but the container shows many errors saying that the configuration files don't exist (that are created with that input). I'll investigate further.
â William Edwards
Feb 7 at 19:30
 |Â
show 1 more comment
up vote
0
down vote
try:
spawn /bin/bash
send "docker run -v $OVPN_DATA:/etc/openvpn --rm -it kylemanna/openvpn ovpn_initpki"
You will need to escape the$
as tcl will expand this within""
. Or you can replace the double quotes byquotes.
â meuh
Feb 7 at 16:51
It's also possible that the quoting can be dropped, and just the -c will be enough to load up bash. Or maybe just quote "docker", though that may not take care of how tcl will handle the variable definitions within the expect file.
â John
Feb 7 at 16:53
bad flag "-c": must be -glob, -regexp, -exact, -notransfer, -nocase, -i, -indices, -iread, -timestamp, -timeout, -nobrace, or --
â William Edwards
Feb 7 at 17:20
The error that you are reporting is from expect. I updated my answer
â John
Feb 7 at 17:52
@JohnW.Gill Not sure what's going on. No errors when I use that code but the container shows many errors saying that the configuration files don't exist (that are created with that input). I'll investigate further.
â William Edwards
Feb 7 at 19:30
 |Â
show 1 more comment
up vote
0
down vote
up vote
0
down vote
try:
spawn /bin/bash
send "docker run -v $OVPN_DATA:/etc/openvpn --rm -it kylemanna/openvpn ovpn_initpki"
try:
spawn /bin/bash
send "docker run -v $OVPN_DATA:/etc/openvpn --rm -it kylemanna/openvpn ovpn_initpki"
edited Feb 7 at 17:50
answered Feb 7 at 16:45
John
419211
419211
You will need to escape the$
as tcl will expand this within""
. Or you can replace the double quotes byquotes.
â meuh
Feb 7 at 16:51
It's also possible that the quoting can be dropped, and just the -c will be enough to load up bash. Or maybe just quote "docker", though that may not take care of how tcl will handle the variable definitions within the expect file.
â John
Feb 7 at 16:53
bad flag "-c": must be -glob, -regexp, -exact, -notransfer, -nocase, -i, -indices, -iread, -timestamp, -timeout, -nobrace, or --
â William Edwards
Feb 7 at 17:20
The error that you are reporting is from expect. I updated my answer
â John
Feb 7 at 17:52
@JohnW.Gill Not sure what's going on. No errors when I use that code but the container shows many errors saying that the configuration files don't exist (that are created with that input). I'll investigate further.
â William Edwards
Feb 7 at 19:30
 |Â
show 1 more comment
You will need to escape the$
as tcl will expand this within""
. Or you can replace the double quotes byquotes.
â meuh
Feb 7 at 16:51
It's also possible that the quoting can be dropped, and just the -c will be enough to load up bash. Or maybe just quote "docker", though that may not take care of how tcl will handle the variable definitions within the expect file.
â John
Feb 7 at 16:53
bad flag "-c": must be -glob, -regexp, -exact, -notransfer, -nocase, -i, -indices, -iread, -timestamp, -timeout, -nobrace, or --
â William Edwards
Feb 7 at 17:20
The error that you are reporting is from expect. I updated my answer
â John
Feb 7 at 17:52
@JohnW.Gill Not sure what's going on. No errors when I use that code but the container shows many errors saying that the configuration files don't exist (that are created with that input). I'll investigate further.
â William Edwards
Feb 7 at 19:30
You will need to escape the
$
as tcl will expand this within ""
. Or you can replace the double quotes by
quotes.â meuh
Feb 7 at 16:51
You will need to escape the
$
as tcl will expand this within ""
. Or you can replace the double quotes by
quotes.â meuh
Feb 7 at 16:51
It's also possible that the quoting can be dropped, and just the -c will be enough to load up bash. Or maybe just quote "docker", though that may not take care of how tcl will handle the variable definitions within the expect file.
â John
Feb 7 at 16:53
It's also possible that the quoting can be dropped, and just the -c will be enough to load up bash. Or maybe just quote "docker", though that may not take care of how tcl will handle the variable definitions within the expect file.
â John
Feb 7 at 16:53
bad flag "-c": must be -glob, -regexp, -exact, -notransfer, -nocase, -i, -indices, -iread, -timestamp, -timeout, -nobrace, or --
â William Edwards
Feb 7 at 17:20
bad flag "-c": must be -glob, -regexp, -exact, -notransfer, -nocase, -i, -indices, -iread, -timestamp, -timeout, -nobrace, or --
â William Edwards
Feb 7 at 17:20
The error that you are reporting is from expect. I updated my answer
â John
Feb 7 at 17:52
The error that you are reporting is from expect. I updated my answer
â John
Feb 7 at 17:52
@JohnW.Gill Not sure what's going on. No errors when I use that code but the container shows many errors saying that the configuration files don't exist (that are created with that input). I'll investigate further.
â William Edwards
Feb 7 at 19:30
@JohnW.Gill Not sure what's going on. No errors when I use that code but the container shows many errors saying that the configuration files don't exist (that are created with that input). I'll investigate further.
â William Edwards
Feb 7 at 19:30
 |Â
show 1 more 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
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f422583%2fhow-do-i-spawn-a-bash-command-in-expect%23new-answer', 'question_page');
);
Post as a guest
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
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
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
2
Don't put the
spawn
command insideexpect
, do what I suggested in your previous questionâ glenn jackman
Feb 7 at 17:31