Giving instructions to an executable in UNIX?
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
New contributor
add a comment |
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
New contributor
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
add a comment |
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
New contributor
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
macos terminal bash unix script
New contributor
New contributor
edited 2 hours ago
bmike♦
158k46284613
158k46284613
New contributor
asked 2 hours ago
Heber AlvarezHeber Alvarez
132
132
New contributor
New contributor
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
add a comment |
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
add a comment |
1 Answer
1
active
oldest
votes
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
.
If you want to send the entire contents of FTIG_dldStruct.txt, it's even easier:./STP <FTIG_dldStruct.txt
.
– Gordon Davisson
53 mins ago
add a comment |
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.
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%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
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
.
If you want to send the entire contents of FTIG_dldStruct.txt, it's even easier:./STP <FTIG_dldStruct.txt
.
– Gordon Davisson
53 mins ago
add a comment |
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
.
If you want to send the entire contents of FTIG_dldStruct.txt, it's even easier:./STP <FTIG_dldStruct.txt
.
– Gordon Davisson
53 mins ago
add a comment |
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
.
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
.
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
53 mins ago
add a comment |
If you want to send the entire contents of FTIG_dldStruct.txt, it's even easier:./STP <FTIG_dldStruct.txt
.
– Gordon Davisson
53 mins ago
If you want to send the entire contents of FTIG_dldStruct.txt, it's even easier:
./STP <FTIG_dldStruct.txt
.– Gordon Davisson
53 mins ago
If you want to send the entire contents of FTIG_dldStruct.txt, it's even easier:
./STP <FTIG_dldStruct.txt
.– Gordon Davisson
53 mins ago
add a comment |
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.
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.
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%2fapple.stackexchange.com%2fquestions%2f349617%2fgiving-instructions-to-an-executable-in-unix%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
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