views:

34

answers:

1

Is there any way to automate the user input in a ksh script?

I realize that in many instances you can create an expect script to do exactly what I am saying, but expect is not installed on the server and there is no chance of that occurring in the near future. But I still need a method of automating user input so the only reaction required is to start the script.

+2  A: 

If you have the complete set of "user" input, you can redirect stdin: script.ksh <userinputfile

If you have some of it, or generate it on the fly, you can use "hereis" documents.

If you are going to be parsing prompts, the easiest way, as you mention, the easiest way is to use Expect. Even if Expect isn't available on the server, it'll be easier for you to include as much Tcl/Expect as necessary to do your parsing than to rewrite and redebug it.

mpez0

related questions