Giving instructions to an executable in UNIX?












2















I'm pretty new at this, so excuse me if this is too easy.
The thing is, I have a bunch of instructions stored in a text file named: 'FTIG_dldStruct.txt' and I want to write them all into an executable named: 'STP'. I wrote this script:



#!/bin/bash
set +H

./STP # This is the executable

for i in {1..586}
do
sed -n -e "$i"p FTIG_dldStruct.txt
done


My program runs the executable, and it asks me for input like this:



STP> # I want the instructions here, but my for loop is not working until I exit the executable.










share|improve this question









New contributor




Heber Alvarez is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
















  • 1





    While MacOS is based on Unix, this is not the Unix stack-exchange. You might find better results on a UNIX-specific board, unless of course your question is actually about MacOS and Terminal

    – Matthew Barclay
    2 hours ago






  • 1





    Welcome Herber - scripting is totally on topic here as on several other sites. No need to go elsewhere unless you don’t get any good answers in 2 weeks time or so. That being said - no worries you are new. Can you edit and clarify - executable normally means a compiled program and scripts / interpreted programs are bash scripts. Are you saying you need to run a program and then process a file when the program ends?

    – bmike
    2 hours ago
















2















I'm pretty new at this, so excuse me if this is too easy.
The thing is, I have a bunch of instructions stored in a text file named: 'FTIG_dldStruct.txt' and I want to write them all into an executable named: 'STP'. I wrote this script:



#!/bin/bash
set +H

./STP # This is the executable

for i in {1..586}
do
sed -n -e "$i"p FTIG_dldStruct.txt
done


My program runs the executable, and it asks me for input like this:



STP> # I want the instructions here, but my for loop is not working until I exit the executable.










share|improve this question









New contributor




Heber Alvarez is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
















  • 1





    While MacOS is based on Unix, this is not the Unix stack-exchange. You might find better results on a UNIX-specific board, unless of course your question is actually about MacOS and Terminal

    – Matthew Barclay
    2 hours ago






  • 1





    Welcome Herber - scripting is totally on topic here as on several other sites. No need to go elsewhere unless you don’t get any good answers in 2 weeks time or so. That being said - no worries you are new. Can you edit and clarify - executable normally means a compiled program and scripts / interpreted programs are bash scripts. Are you saying you need to run a program and then process a file when the program ends?

    – bmike
    2 hours ago














2












2








2








I'm pretty new at this, so excuse me if this is too easy.
The thing is, I have a bunch of instructions stored in a text file named: 'FTIG_dldStruct.txt' and I want to write them all into an executable named: 'STP'. I wrote this script:



#!/bin/bash
set +H

./STP # This is the executable

for i in {1..586}
do
sed -n -e "$i"p FTIG_dldStruct.txt
done


My program runs the executable, and it asks me for input like this:



STP> # I want the instructions here, but my for loop is not working until I exit the executable.










share|improve this question









New contributor




Heber Alvarez is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












I'm pretty new at this, so excuse me if this is too easy.
The thing is, I have a bunch of instructions stored in a text file named: 'FTIG_dldStruct.txt' and I want to write them all into an executable named: 'STP'. I wrote this script:



#!/bin/bash
set +H

./STP # This is the executable

for i in {1..586}
do
sed -n -e "$i"p FTIG_dldStruct.txt
done


My program runs the executable, and it asks me for input like this:



STP> # I want the instructions here, but my for loop is not working until I exit the executable.







macos terminal bash unix script






share|improve this question









New contributor




Heber Alvarez is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




Heber Alvarez is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited 2 hours ago









bmike

158k46284613




158k46284613






New contributor




Heber Alvarez is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked 2 hours ago









Heber AlvarezHeber Alvarez

132




132




New contributor




Heber Alvarez is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Heber Alvarez is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Heber Alvarez is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.








  • 1





    While MacOS is based on Unix, this is not the Unix stack-exchange. You might find better results on a UNIX-specific board, unless of course your question is actually about MacOS and Terminal

    – Matthew Barclay
    2 hours ago






  • 1





    Welcome Herber - scripting is totally on topic here as on several other sites. No need to go elsewhere unless you don’t get any good answers in 2 weeks time or so. That being said - no worries you are new. Can you edit and clarify - executable normally means a compiled program and scripts / interpreted programs are bash scripts. Are you saying you need to run a program and then process a file when the program ends?

    – bmike
    2 hours ago














  • 1





    While MacOS is based on Unix, this is not the Unix stack-exchange. You might find better results on a UNIX-specific board, unless of course your question is actually about MacOS and Terminal

    – Matthew Barclay
    2 hours ago






  • 1





    Welcome Herber - scripting is totally on topic here as on several other sites. No need to go elsewhere unless you don’t get any good answers in 2 weeks time or so. That being said - no worries you are new. Can you edit and clarify - executable normally means a compiled program and scripts / interpreted programs are bash scripts. Are you saying you need to run a program and then process a file when the program ends?

    – bmike
    2 hours ago








1




1





While MacOS is based on Unix, this is not the Unix stack-exchange. You might find better results on a UNIX-specific board, unless of course your question is actually about MacOS and Terminal

– Matthew Barclay
2 hours ago





While MacOS is based on Unix, this is not the Unix stack-exchange. You might find better results on a UNIX-specific board, unless of course your question is actually about MacOS and Terminal

– Matthew Barclay
2 hours ago




1




1





Welcome Herber - scripting is totally on topic here as on several other sites. No need to go elsewhere unless you don’t get any good answers in 2 weeks time or so. That being said - no worries you are new. Can you edit and clarify - executable normally means a compiled program and scripts / interpreted programs are bash scripts. Are you saying you need to run a program and then process a file when the program ends?

– bmike
2 hours ago





Welcome Herber - scripting is totally on topic here as on several other sites. No need to go elsewhere unless you don’t get any good answers in 2 weeks time or so. That being said - no worries you are new. Can you edit and clarify - executable normally means a compiled program and scripts / interpreted programs are bash scripts. Are you saying you need to run a program and then process a file when the program ends?

– bmike
2 hours ago










1 Answer
1






active

oldest

votes


















3














It appears you want to send some number (586?) lines from FTIG_dldStruct.txt to the ./STP command? If so, assuming ./STP reads from standard input as is typical, that may look like:



head -n 586 FTIG_dldStruct.txt | ./STP


If you need ./STP to stick around after those commands are entered so the program can be interacted with, that's a more complicated issue and typically requires something like expect.






share|improve this answer
























  • If you want to send the entire contents of FTIG_dldStruct.txt, it's even easier: ./STP <FTIG_dldStruct.txt.

    – Gordon Davisson
    39 mins ago











Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "118"
};
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',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});






Heber Alvarez is a new contributor. Be nice, and check out our Code of Conduct.










draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fapple.stackexchange.com%2fquestions%2f349617%2fgiving-instructions-to-an-executable-in-unix%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









3














It appears you want to send some number (586?) lines from FTIG_dldStruct.txt to the ./STP command? If so, assuming ./STP reads from standard input as is typical, that may look like:



head -n 586 FTIG_dldStruct.txt | ./STP


If you need ./STP to stick around after those commands are entered so the program can be interacted with, that's a more complicated issue and typically requires something like expect.






share|improve this answer
























  • If you want to send the entire contents of FTIG_dldStruct.txt, it's even easier: ./STP <FTIG_dldStruct.txt.

    – Gordon Davisson
    39 mins ago
















3














It appears you want to send some number (586?) lines from FTIG_dldStruct.txt to the ./STP command? If so, assuming ./STP reads from standard input as is typical, that may look like:



head -n 586 FTIG_dldStruct.txt | ./STP


If you need ./STP to stick around after those commands are entered so the program can be interacted with, that's a more complicated issue and typically requires something like expect.






share|improve this answer
























  • If you want to send the entire contents of FTIG_dldStruct.txt, it's even easier: ./STP <FTIG_dldStruct.txt.

    – Gordon Davisson
    39 mins ago














3












3








3







It appears you want to send some number (586?) lines from FTIG_dldStruct.txt to the ./STP command? If so, assuming ./STP reads from standard input as is typical, that may look like:



head -n 586 FTIG_dldStruct.txt | ./STP


If you need ./STP to stick around after those commands are entered so the program can be interacted with, that's a more complicated issue and typically requires something like expect.






share|improve this answer













It appears you want to send some number (586?) lines from FTIG_dldStruct.txt to the ./STP command? If so, assuming ./STP reads from standard input as is typical, that may look like:



head -n 586 FTIG_dldStruct.txt | ./STP


If you need ./STP to stick around after those commands are entered so the program can be interacted with, that's a more complicated issue and typically requires something like expect.







share|improve this answer












share|improve this answer



share|improve this answer










answered 2 hours ago









thrigthrig

63935




63935













  • If you want to send the entire contents of FTIG_dldStruct.txt, it's even easier: ./STP <FTIG_dldStruct.txt.

    – Gordon Davisson
    39 mins ago



















  • If you want to send the entire contents of FTIG_dldStruct.txt, it's even easier: ./STP <FTIG_dldStruct.txt.

    – Gordon Davisson
    39 mins ago

















If you want to send the entire contents of FTIG_dldStruct.txt, it's even easier: ./STP <FTIG_dldStruct.txt.

– Gordon Davisson
39 mins ago





If you want to send the entire contents of FTIG_dldStruct.txt, it's even easier: ./STP <FTIG_dldStruct.txt.

– Gordon Davisson
39 mins ago










Heber Alvarez is a new contributor. Be nice, and check out our Code of Conduct.










draft saved

draft discarded


















Heber Alvarez is a new contributor. Be nice, and check out our Code of Conduct.













Heber Alvarez is a new contributor. Be nice, and check out our Code of Conduct.












Heber Alvarez is a new contributor. Be nice, and check out our Code of Conduct.
















Thanks for contributing an answer to Ask Different!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fapple.stackexchange.com%2fquestions%2f349617%2fgiving-instructions-to-an-executable-in-unix%23new-answer', 'question_page');
}
);

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







Popular posts from this blog

What other Star Trek series did the main TNG cast show up in?

Berlina muro

Berlina aerponto