I am trying to send commands to the bash shell through a webpage and echo the results to the webpage. The php echo '....' command works great to output the results of terminal commands.
My C program acts like a terminal itself, in that it continuously prompts the user for input and spits out the corresponding data correlating to the input.
:~$ sudo ./program program_prompt> command1 process has started program_prompt> command2 process ended The output is foo bar program_prompt> ^C :~$ :~$
I want to enter inputs into my fake terminal and continue to be able to enter inputs. From what I have gathered, I can pipe in strings into a command and sort of do this.
echo "command1" | sudo ./program
This is the closest I have gotten to entering commands into my fake terminal. The fake terminal immediately ends after executing this command. I never get a chance to enter command2 and see the output. Im pushed back into the real terminal :~$
:~$ echo "command1" | sudo ./program program_prompt> command1 process has started program_prompt> :~$
I dont know if this is the proper path to do this. If I can do something different in php, js, or jquery to also accomplish please post a method.