views:

17

answers:

3

I have to use a provided script that takes user input while the script is running instead of parameters. I can't get around this.

An example of script would be:

#!/bin/bash

echo "param one"
read one
doSomething

echo "param two"
read two
doSomething

echo "param three"
read three
doSomething

echo "param four"
read four
doSomething

echo "param five"
read five
doSomething

I would like a way to be able to call this script and provide parameterized input, something like:

./scriptNameWrapper.ksh 1 22 333 4444 55555

I've tried googling, and either I'm not asking the question correctly, or more likely I can't see the wood for the trees.

I've tried this, which doesn't work:

#!/bin/bash

./scriptName.ksh
<<$1
<<$2
<<$3
<<$4
<<$5

I'm clearly not a *nix expert, but I'm sure I've seen this done before, I just can't find any examples out there. This is beginning to get frustrating, and any help would be greatly appreciated.

+1  A: 

Put your paramaters in a file one per line then run

./scriptName.ksh <filename
Steve Weet
+1  A: 

Call your script like this:

echo -e "Param1\nParam2\nParam3" | ./scriptName.ksh

The \n sequence between each parameter emulates the enter key being pressed.

bdk
+1  A: 

What you've probably seen, based on your attempt, is called a here-document.

It should look like this:

#!/bin/bash

./scriptName.ksh <<-END_PARAMS
    $1
    $2
    $3
    $4
    $5
END_PARAMS
pra