How do I spawn a BASH command in expect?

The name of the pictureThe name of the pictureThe name of the pictureClash 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?







share|improve this question
















  • 2




    Don't put the spawn command inside expect, do what I suggested in your previous question
    – glenn jackman
    Feb 7 at 17:31














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?







share|improve this question
















  • 2




    Don't put the spawn command inside expect, do what I suggested in your previous question
    – glenn jackman
    Feb 7 at 17:31












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?







share|improve this question












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?









share|improve this question











share|improve this question




share|improve this question










asked Feb 7 at 16:39









William Edwards

3211420




3211420







  • 2




    Don't put the spawn command inside expect, do what I suggested in your previous question
    – glenn jackman
    Feb 7 at 17:31












  • 2




    Don't put the spawn command inside expect, 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










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 ..."





share|improve this answer




















  • the -- probably shouldn't be placed after bash and before bash flags ...
    – thrig
    Feb 7 at 17:56

















up vote
0
down vote













try:



spawn /bin/bash
send "docker run -v $OVPN_DATA:/etc/openvpn --rm -it kylemanna/openvpn ovpn_initpki"





share|improve this answer






















  • 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











  • 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











Your Answer







StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);








 

draft saved


draft discarded


















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






























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 ..."





share|improve this answer




















  • the -- probably shouldn't be placed after bash and before bash flags ...
    – thrig
    Feb 7 at 17:56














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 ..."





share|improve this answer




















  • the -- probably shouldn't be placed after bash and before bash flags ...
    – thrig
    Feb 7 at 17:56












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 ..."





share|improve this answer












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 ..."






share|improve this answer












share|improve this answer



share|improve this answer










answered Feb 7 at 17:48









Wouter Verhelst

7,156831




7,156831











  • 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















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












up vote
0
down vote













try:



spawn /bin/bash
send "docker run -v $OVPN_DATA:/etc/openvpn --rm -it kylemanna/openvpn ovpn_initpki"





share|improve this answer






















  • 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











  • 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















up vote
0
down vote













try:



spawn /bin/bash
send "docker run -v $OVPN_DATA:/etc/openvpn --rm -it kylemanna/openvpn ovpn_initpki"





share|improve this answer






















  • 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











  • 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













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"





share|improve this answer














try:



spawn /bin/bash
send "docker run -v $OVPN_DATA:/etc/openvpn --rm -it kylemanna/openvpn ovpn_initpki"






share|improve this answer














share|improve this answer



share|improve this answer








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 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











  • 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










  • 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













 

draft saved


draft discarded


























 


draft saved


draft discarded














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













































































Popular posts from this blog

How to check contact read email or not when send email to Individual?

Displaying single band from multi-band raster using QGIS

How many registers does an x86_64 CPU actually have?