Eval201 » Historique » Version 4
François Rioult, 22/06/2010 22:48
| 1 | 1 | François Rioult | h1. Eval201 |
|---|---|---|---|
| 2 | |||
| 3 | h2. Synopsis |
||
| 4 | |||
| 5 | This operator has two parameters and no input. The corresponding shell script executes the two parameters as a command, and copies the result in the output. |
||
| 6 | |||
| 7 | It is useful for commands with arguments, such as @awk@ commands whose arguments include space, quotes, etc., that could not be written with only one parameter in [[eval101]]. It can also produce file with commands using the parameters given by Ariane. |
||
| 8 | |||
| 9 | h2. Parameters |
||
| 10 | |||
| 11 | 2 parameters, treated as the command to be executed. |
||
| 12 | |||
| 13 | h2. Inputs |
||
| 14 | |||
| 15 | No input |
||
| 16 | |||
| 17 | h2. Outputs |
||
| 18 | |||
| 19 | 1 output: the result of the command |
||
| 20 | |||
| 21 | 4 | François Rioult | h2. Shell code |
| 22 | |||
| 23 | <pre> |
||
| 24 | cmd=$1; shift |
||
| 25 | args=$1; shift |
||
| 26 | output=$1; shift |
||
| 27 | |||
| 28 | $cmd $args > $output |
||
| 29 | </pre> |
||
| 30 | |||
| 31 | 1 | François Rioult | h2. Example |
| 32 | |||
| 33 | This operator can be used for generating a file with an @awk@ instruction, for example: |
||
| 34 | <pre> |
||
| 35 | awk '{for(i=1;i<=10;i++)printf("train.%d", i)} input > output |
||
| 36 | </pre> |
||
| 37 | |||
| 38 | 3 | François Rioult | See the scenario [[perturbation.aws]], where this operator uses @echo@ for saving a parameter in a file. |