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


As pointed out in the comments to pass the entire contents of the file that would be:

./STP &lt; FTIG_dldStruct.txt


Various pipelines are also possible, perhaps to filter out comments (here arbitrarily defined as lines beginning with #) with grep:

grep -v '^#' 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 an expect script that in turn wraps around ./STP.

#!/usr/bin/env expect -f
set filehandle [open "FTIG_dldStruct.txt"]
set maxlines 586
spawn -noecho ./STP
while {[gets $filehandle line] &gt;= 0 &amp;&amp; $maxlines &gt; 0} {
    # wait for prompt from program
    expect -ex "STP&gt;"
    send "$line\r"
    incr maxlines -1
}
# turn interaction with the program over to the user
interact


This code would need to be saved to a file and made executable like any other script on unix. expect has also been made available as a library in various other programming languages.