Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jun 17th, 2006, 2:30 PM   #1
hush
Programmer
 
hush's Avatar
 
Join Date: Feb 2006
Location: 127.0.0.1
Posts: 35
Rep Power: 0 hush is on a distinguished road
what is this called

I script with ksh.

I run a script and this calls a couple of programs, these programs then request input for example:

Would you like to back up the table structure also (y/n)?

I’m not sure what language they are in.

What is it referred to in programming when I want to put input into these requests with a script rather then having to do it manually?

If I can find out this then I got a chance at googling it.

Thanks

hush
hush is offline   Reply With Quote
Old Jun 17th, 2006, 2:47 PM   #2
Arevos
Programming Guru
 
Arevos's Avatar
 
Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 4 Arevos is on a distinguished road
Not quite sure what you're asking. Most console scripts get input from the user via STDIN, and report back via STDOUT. You can pipe the STDOUT from one program to the STDIN of another by using pipes.

For example, the command "yes" outputs a continual stream of identical lines. By default, it's "y". Thus, by piping "yes" to a different program, you can get it to answer "y" to every question posed:
yes | some_program
If you want something more complex, then you can pipe a file in:
some_file > some_program
Or create some program of your own to generate the output.
Arevos is offline   Reply With Quote
Old Jun 18th, 2006, 7:23 AM   #3
hush
Programmer
 
hush's Avatar
 
Join Date: Feb 2006
Location: 127.0.0.1
Posts: 35
Rep Power: 0 hush is on a distinguished road
Thanks for the reply arevos.

Sorry I could not be clearer in my explanation.

I’m aware of pipes.

What about if the program requests multiple standard inputs?

Could I use a file?

How would it be structured e.g would I use \n to move onto the next standard input?

I would have tried this but the unix box I use at work is a production system.

Is there another way to supply standard input; if so what is it called ? (this is the issue I was attempting to ask a question on in my first post)

hush
hush is offline   Reply With Quote
Old Jun 18th, 2006, 11:20 AM   #4
Arevos
Programming Guru
 
Arevos's Avatar
 
Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 4 Arevos is on a distinguished road
Your question isn't clear. There are multiple ways to input data into a program; via a GUI interface, via a TCP socket, via a file - the list goes on. The standard way of inputting data to console applications is STDIN, which most non-GUI console applications use. If you want to mix user input with automated input via STDIN in a custom arrangement, you'll probably need a more powerful scripting language than KSH. Possibly something like Perl or Python.
Arevos is offline   Reply With Quote
Old Jun 18th, 2006, 2:19 PM   #5
hush
Programmer
 
hush's Avatar
 
Join Date: Feb 2006
Location: 127.0.0.1
Posts: 35
Rep Power: 0 hush is on a distinguished road
i found this:

http://en.wikipedia.org/wiki/Expect

what i was asking is not possible without a tool like this.

cheers anyway.

hush
hush is offline   Reply With Quote
Old Jun 19th, 2006, 9:00 AM   #6
jim mcnamara
Hobbyist Programmer
 
Join Date: Jun 2005
Location: New Mexico
Posts: 228
Rep Power: 4 jim mcnamara is on a distinguished road
Do you know about the here document?
/path/to/myprogram $USER $PASS<<EOF
answer to question 1
output file filname
EOF

This is essentially what expect does. It knows the questions and answers ahead of time.
jim mcnamara is offline   Reply With Quote
Old Jun 21st, 2006, 4:50 PM   #7
hush
Programmer
 
hush's Avatar
 
Join Date: Feb 2006
Location: 127.0.0.1
Posts: 35
Rep Power: 0 hush is on a distinguished road
no, i will look into that cheers.
hush is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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 On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 5:12 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC