![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Programmer
Join Date: Feb 2006
Location: 127.0.0.1
Posts: 35
Rep Power: 0
![]() |
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 |
|
|
|
|
|
#2 |
|
Programming Guru
![]() Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 4
![]() |
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 some_file > some_program |
|
|
|
|
|
#3 |
|
Programmer
Join Date: Feb 2006
Location: 127.0.0.1
Posts: 35
Rep Power: 0
![]() |
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 |
|
|
|
|
|
#4 |
|
Programming Guru
![]() Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 4
![]() |
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.
|
|
|
|
|
|
#5 |
|
Programmer
Join Date: Feb 2006
Location: 127.0.0.1
Posts: 35
Rep Power: 0
![]() |
i found this:
http://en.wikipedia.org/wiki/Expect what i was asking is not possible without a tool like this. cheers anyway. hush |
|
|
|
|
|
#6 |
|
Hobbyist Programmer
Join Date: Jun 2005
Location: New Mexico
Posts: 228
Rep Power: 4
![]() |
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. |
|
|
|
|
|
#7 |
|
Programmer
Join Date: Feb 2006
Location: 127.0.0.1
Posts: 35
Rep Power: 0
![]() |
no, i will look into that cheers.
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|