LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 08-02-2005, 06:57 PM   #1
quarry_06
Member
 
Registered: Oct 2004
Posts: 77

Rep: Reputation: 15
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
 
Old 08-02-2005, 07:12 PM   #2
J3N7iL
Member
 
Registered: Jun 2004
Location: Chicago
Distribution: Gentoo
Posts: 53

Rep: Reputation: 15
like this

ping google.com --> googleping.txt
 
Old 08-02-2005, 07:26 PM   #3
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 22,978
Blog Entries: 11

Rep: Reputation: 879Reputation: 879Reputation: 879Reputation: 879Reputation: 879Reputation: 879Reputation: 879
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
 
Old 08-02-2005, 07:38 PM   #4
quarry_06
Member
 
Registered: Oct 2004
Posts: 77

Original Poster
Rep: Reputation: 15
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

Last edited by quarry_06; 08-02-2005 at 07:41 PM.
 
Old 08-02-2005, 07:44 PM   #5
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 22,978
Blog Entries: 11

Rep: Reputation: 879Reputation: 879Reputation: 879Reputation: 879Reputation: 879Reputation: 879Reputation: 879
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.
 
Old 08-02-2005, 07:48 PM   #6
quarry_06
Member
 
Registered: Oct 2004
Posts: 77

Original Poster
Rep: Reputation: 15
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
 
Old 08-02-2005, 07:55 PM   #7
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 22,978
Blog Entries: 11

Rep: Reputation: 879Reputation: 879Reputation: 879Reputation: 879Reputation: 879Reputation: 879Reputation: 879
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
 
Old 08-02-2005, 09:47 PM   #8
J3N7iL
Member
 
Registered: Jun 2004
Location: Chicago
Distribution: Gentoo
Posts: 53

Rep: Reputation: 15
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
 
Old 08-03-2005, 12:24 AM   #9
hk_linux
Member
 
Registered: Nov 2004
Location: India
Distribution: RedHat, PCQLinux, Fedora
Posts: 95

Rep: Reputation: 15
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
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How does the 64 bit version handle interacting with 32 bit programs? purelithium Mandriva 1 11-13-2005 05:16 PM
can not see the prompt ustek Slackware 5 02-13-2004 02:56 PM
Why Does Prompt Look Like ... Rubicone Linux - Newbie 5 03-19-2002 10:56 AM
Prompt Atroxic Linux - Newbie 5 01-09-2002 04:43 AM
Prompt name toxic53 Linux - General 1 09-26-2001 11:49 AM


All times are GMT -5. The time now is 05:36 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration