LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   interacting with prompt (https://www.linuxquestions.org/questions/programming-9/interacting-with-prompt-349390/)

quarry_06 08-02-2005 06:57 PM

interacting with prompt
 
hi
I have a program which basically opens a new prompt, say like gnuplot would. now I want to be able to send commands to that prompt and retrieve the output and write it to a file.

anyone a suggestion on how to do that?

quarry 06

J3N7iL 08-02-2005 07:12 PM

like this

ping google.com --> googleping.txt

Tinkster 08-02-2005 07:26 PM

Re: interacting with prompt
 
Quote:

Originally posted by quarry_06
hi
I have a program which basically opens a new prompt, say like gnuplot would. now I want to be able to send commands to that prompt and retrieve the output and write it to a file.

anyone a suggestion on how to do that?

quarry 06

You'll be looking at script to record the session, and
expect for interaction.


Cheers,
Tink

quarry_06 08-02-2005 07:38 PM

Re: Re: interacting with prompt
 
Quote:

Originally posted by Tinkster
You'll be looking at script to record the session, and
expect for interaction.


Cheers,
Tink

Sorry, I don't understand. looking at What script? recording is ok, but I need to send multiple commands to this prompt.

I guess I haven't explained very well.
I call gnuplot from a shell script. then I want to type into the gnuplot prompt, but from withing my shell script.

thanks

Tinkster 08-02-2005 07:44 PM

Re: Re: Re: interacting with prompt
 
Quote:

Originally posted by quarry_06
Sorry, I don't understand. looking at What script? recording is ok, but I need to send multiple commands to this prompt.

I guess I haven't explained very well.
I call gnuplot from a shell script. then I want to type into the gnuplot prompt, but from withing my shell script.

thanks

That's where expect comes in ...

It allows you to script interactive sessions.



Cheers,
Tink

P.S.: Could you please a) shorten your sig and b) stick
with English? Thanks.

quarry_06 08-02-2005 07:48 PM

i still don't understand your expect, but I found what I was looking for.
It is called a "here" function
and goes like this

gnuplot
<<**
do
whatever
you
want
to
do
**

can you still explain what your explain does/how it works?

and hey, I would love it if other users had sigs in other languages, so I could learn something new !

anyway thanks

Tinkster 08-02-2005 07:55 PM

Quote:

Originally posted by quarry_06
i still don't understand your expect, but I found what I was looking for.
It is called a "here" function
and goes like this

gnuplot
<<**
do
whatever
you
want
to
do
**

can you still explain what your explain does/how it works?

I don't know how GNU Plot works ... here documents are
going to be fine for one-of activities. If you for example
have something that will ask something, expect input, do
some more, then ask something new expect is the tool
for you. ...


Quote:

Originally posted by quarry_06
and hey, I would love it if other users had sigs in other languages, so I could learn something new !

anyway thanks

Good for you :) ... however, it would be a bit
much to ask of mods to learn all possible lingos
on the boards to make sure the contents is OK ;}



Cheers,
Tink

J3N7iL 08-02-2005 09:47 PM

no seirously!

open your home folder
open a terminal and cd to your home folder

type

Code:

ping google.com --> googleping.txt
it will place all out put into the file called googleping.txt

hk_linux 08-03-2005 12:24 AM

Quote:

Originally posted by quarry_06

can you still explain what your explain does/how it works?

I beleive you are asking about expect.
The following links can be of use...

http://expect.nist.gov/
http://www.oreilly.com/catalog/expect/chapter/ch03.html


All times are GMT -5. The time now is 09:55 PM.