Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I am using text to speech program to read a text file..
As soon as i execute the command
flite -pw alice.txt
It speak out the alice.txt file and simultaneously prints the text which was read...Now i want this text i.e, the text printed on stdout to be redirected to a file..
This can be done easily with redirection...but my problem is, since alice.txt is big it takes long time to speak out and read it...only after completion of this process i am able to redirect it to a file...i want to read the stdout instantaneously and write it into a file...(while flite is writing to stdout at the same time i want to read and write it in to file)
I tried popen, redirection command..nothing was useful..
Thanks for your reply...This is the program that i used to test the tee command...
#include <stdio.h>
int main()
{
int pid;
pid =fork();
if (pid ==0) //Executed by the child process
{
printf("\nChild process activated\n");
system("tee stdoutput.txt");
}
else //Executed by the parent process
{
printf("\nParent process activated\n");
system("flite -pw alice");
}
}
The tee command is better used at the shell level rather than being called from your application. The following will display the flite's normal output on stdout as well as writing it to stdoutput.txt:
I executed the above command in one terminal and opened another terminal where i opened stdoutput.txt...
vi stdoutput.txt
I am not able to see the output...
What happens is, only after completing the command flite -pw alice.txt, that is only after reading the entire file alice.txt and printing into stdout, the stdout is transferred to stdoutput.txt...
It is not like printing the output to stdoutput as well as to stdoutput.txt at the sametime...But i want the my stdoutput.txt to reflect changes at the same time when stdoutput is changing...the change should be instantaneous...
In the 2nd terminal, use
tail -f stdoutput.txt
which should be better, but note there is always a certain amt of buffering going on in the background by the OS.
Incidentally, why 'instantaneously'? What's the rush?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.