Cannot redirect to STDIN in a shell script

I am unable to use STDIn redirection with < (commands)
When I do the following, both approaches work and give the same results:

$ printf "aaa\nbbb\n" > file1
$ printf "111\n222\n" > file2
$ cat file1 file2
aaa
bbb
111
222
$ cat <(printf "aaa\nbbb\n") <(printf "111\n222\n")
aaa
bbb
111
222

However, the second approach won't work when I put in in a script.

I am using Cygwin1.5.25-15

Any clue?

From the manual page of cat:

...
cat - concatenate files and print on the standard output
...

You should feed the cat with files to hear it purr.

What I don't understand is that the command with < () redirection works perfectly as a single line, but not when included in a script.

Thats the issue with the emulators. Dont get confused, emulators are not real shells, they are made to mimic some of the qualities of shells ! If you try that on a Bash/sh/ksh/csh it will works fine.
-Peace

Thanks, but apparently this goes beyond the Cygwin element.

I tried that on a Linux bash:

  1. Works fine as a line:
-bash-3.1$ cat <(printf "aaa\nbbb\n") <(printf "111\n222\n")
aaa
bbb
111
222
  1. Won't work as a script:
 
-rw-r--r-- 1 cleseb01 cleseb01 51 Feb 11 16:27 script
-bash-3.1$ cat script 
cat <(printf "aaa\nbbb\n") <(printf "111\n222\n")
 
-bash-3.1$ sh script 
script: line 1: syntax error near unexpected token `('
script: line 1: `cat <(printf "aaa\nbbb\n") <(printf "111\n222\n")'
 
-bash-3.1$ cat myScript 
#!/bin/bash
cat <(printf "aaa\nbbb\n") <(printf "111\n222\n")

$ cat script
#!/bin/bash
cat <(printf "aaa\nbbb\n") <(printf "111\n222\n")
 
$ sh script
script: line 2: syntax error near unexpected token `('
script: line 2: `cat <(printf "aaa\nbbb\n") <(printf "111\n222\n")'

Unix 101:
1)The 1st line you are placing in a shell script is which shell you want to run the command in.
2)if you trying to run a script as "sh script" you are saying run the set of commands in script in sh(bourne shell). And any line starting with # is a comment and so the 1st line has no significance.
3)If you want to run your script your way try "bash script" and it will work fine. Else change the mode on the file to have execute bit (chmod +x script)and you could run the script as ./script from the dir where it is located.

Peace

not that it matters, but... don't name your script 'script' - there's a well-known UNIX tool called 'script' - do 'man script'.