Prev: Question about shift and remains value
Next: Bash bug?
From: Chengj on 15 Jul 2010 09:02 Hi take a short code as example,the code calculate the product of two real numbers $cat in 2 5 $exec <in >out 2>&1 $cat out please input the first real number: please input the second real number: the product is: 10 but i want the file out should be read $cat out please input the first real number: 2 please input the second real number: 5 the product is: 10 i.e. i want duplicate stdin simultaneously after each input, is that possible? --- news://freenews.netfront.net/ - complaints: news(a)netfront.net ---
From: Barry Margolin on 15 Jul 2010 20:39 In article <i1n0s9$2193$1(a)adenine.netfront.net>, "Chengj" <guan-junchen(a)hotmail.com> wrote: > Hi > > take a short code as example,the code calculate the product > of two real numbers > $cat in > 2 > 5 > $exec <in >out 2>&1 Is there supposed to be something here that runs the program that displays those prompts and calculates the product? > $cat out > please input the first real number: > please input the second real number: > the product is: 10 > > but i want the file out should be read > $cat out > please input the first real number: 2 > please input the second real number: 5 > the product is: 10 > > i.e. i want duplicate stdin simultaneously after each input, is that > possible? Use "script" to capture an entire session. -- Barry Margolin, barmar(a)alum.mit.edu Arlington, MA *** PLEASE post questions in newsgroups, not directly to me *** *** PLEASE don't copy me on replies, I'll read them in the group ***
From: Chen g j on 16 Jul 2010 02:01 "Barry Margolin" <barmar(a)alum.mit.edu> :barmar-42A0FD.20393615072010(a)reserved-multicast-range-not-delegated.example.com... > In article <i1n0s9$2193$1(a)adenine.netfront.net>, > "Chengj" <guan-junchen(a)hotmail.com> wrote: > >> Hi >> >> take a short code as example,the code calculate the product >> of two real numbers >> $cat in >> 2 >> 5 >> $exec <in >out 2>&1 > > Is there supposed to be something here that runs the program that > displays those prompts and calculates the product? Yes > >> $cat out >> please input the first real number: >> please input the second real number: >> the product is: 10 >> >> but i want the file out should be read >> $cat out >> please input the first real number: 2 >> please input the second real number: 5 >> the product is: 10 >> >> i.e. i want duplicate stdin simultaneously after each input, is that >> possible? > > Use "script" to capture an entire session. Hi, Thank you!! When i run the "exec" interactively, the "script" captures the contents that display to screen, including the input from keyboard. But when i run the "exec" by redirecting the "stdin" to file "in", the input can not be displayed to screen(i use fedora 5), thus, it seems the "script" doesn't work for this situation. now i have a batch bash script that runs many (Fortran) programs one by one, and each individual program is feeded from a "in" file, i cannot run the batch script interactively from keyboard input, so, have any suggestions for me? sorry for my poor english. > > -- > Barry Margolin, barmar(a)alum.mit.edu > Arlington, MA > *** PLEASE post questions in newsgroups, not directly to me *** > *** PLEASE don't copy me on replies, I'll read them in the group ***
From: Barry Margolin on 16 Jul 2010 22:11 In article <i1osg9$l7$1(a)www.shinco.com>, "Chen g j" <guan-junchen(a)hotmail.com> wrote: > "Barry Margolin" <barmar(a)alum.mit.edu> > :barmar-42A0FD.20393615072010(a)reserved-multicast-range-not-delegated.example.c > om... > > In article <i1n0s9$2193$1(a)adenine.netfront.net>, > > "Chengj" <guan-junchen(a)hotmail.com> wrote: > > > >> Hi > >> > >> take a short code as example,the code calculate the product > >> of two real numbers > >> $cat in > >> 2 > >> 5 > >> $exec <in >out 2>&1 > > > > Is there supposed to be something here that runs the program that > > displays those prompts and calculates the product? > Yes > > > > >> $cat out > >> please input the first real number: > >> please input the second real number: > >> the product is: 10 > >> > >> but i want the file out should be read > >> $cat out > >> please input the first real number: 2 > >> please input the second real number: 5 > >> the product is: 10 > >> > >> i.e. i want duplicate stdin simultaneously after each input, is that > >> possible? > > > > Use "script" to capture an entire session. > > Hi, Thank you!! > > When i run the "exec" interactively, the "script" captures the contents > that display to screen, including the input from keyboard. > But when i run the "exec" by redirecting the "stdin" to file > "in", the input can not be displayed to screen(i use fedora 5), thus, it > seems the "script" doesn't work for this situation. > > now i have a batch bash script that runs many (Fortran) programs one by one, > and each individual program is feeded from a "in" file, > i cannot run the batch script interactively from keyboard input, > so, have any suggestions for me? You're right, I was confused. "script" captures terminal input and output, not program input and output. I don't think there's any built-in way to do what you want. I think there might be a way to do it by writing an "expect" script that feeds the data to the program. -- Barry Margolin, barmar(a)alum.mit.edu Arlington, MA *** PLEASE post questions in newsgroups, not directly to me *** *** PLEASE don't copy me on replies, I'll read them in the group ***
|
Pages: 1 Prev: Question about shift and remains value Next: Bash bug? |