Unix Programming - Korn Shell Script

This is Interesting: Free IT Magazines  
Home > Archive > Unix Programming > September 2006 > Korn Shell Script





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Korn Shell Script
Roman

2006-09-16, 1:43 pm

I am trying to set up an automatic execution of a Java package which
accepts values from a number of prompts.

For instance,


The execution line is as follows:


[abc] ~/dfg > Java -jar abc.jar


Platform Options Available:
[1] Windows
[2] Unix


Choose: 2


Database
[1] Oracle
[2] UDB


Choose: 1


etc...


How do I automatically run this using ksh without user input?


Thanks in advance

Chris F.A. Johnson

2006-09-16, 1:43 pm

On 2006-09-13, Roman wrote:
> I am trying to set up an automatic execution of a Java package which
> accepts values from a number of prompts.
>
> For instance,
>
>
> The execution line is as follows:
>
>
> [abc] ~/dfg > Java -jar abc.jar
>
>
> Platform Options Available:
> [1] Windows
> [2] Unix
>
>
> Choose: 2
>
>
> Database
> [1] Oracle
> [2] UDB
>
>
> Choose: 1
>
>
> etc...
>
>
> How do I automatically run this using ksh without user input?


If it reads from the standard input:

printf "%s\n" 2 1 | Java -jar abc.jar

If not, you can use 'expect'.

--
Chris F.A. Johnson, author | <http://cfaj.freeshell.org>
Shell Scripting Recipes: | My code in this post, if any,
A Problem-Solution Approach | is released under the
2005, Apress | GNU General Public Licence
Roman

2006-09-16, 1:43 pm

Thanks for your help.

I have used expect, but it doesn't seem to work. Perhaps I code it
wrong. Here is the code

#!/usr/bin/expect
java -jar abc.jar
expect ".*"
send "2\r"
expect eof


Chris F.A. Johnson wrote:
> On 2006-09-13, Roman wrote:
>
> If it reads from the standard input:
>
> printf "%s\n" 2 1 | Java -jar abc.jar
>
> If not, you can use 'expect'.
>
> --
> Chris F.A. Johnson, author | <http://cfaj.freeshell.org>
> Shell Scripting Recipes: | My code in this post, if any,
> A Problem-Solution Approach | is released under the
> 2005, Apress | GNU General Public Licence


Roman

2006-09-16, 1:43 pm

Never mind. My mistake.

I didn't use spawn.

Roman wrote:[vbcol=seagreen]
> Thanks for your help.
>
> I have used expect, but it doesn't seem to work. Perhaps I code it
> wrong. Here is the code
>
> #!/usr/bin/expect
> Java -jar abc.jar
> expect ".*"
> send "2\r"
> expect eof
>
>
> Chris F.A. Johnson wrote:

Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com