Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.
#!/bin/sh
#myVar=`date`#case 1
#myVar=`cat /dev/stdin`#case 2
myVar=($(< /dev/stdin)) #case 3
echo $myVar
exit 2

case 1 works case 2 and 3 don't work. When I test with either 2 or 3; there is no output and the script never exits

What I eventually require is to read from the stdin written to by the postfix pipe

share|improve this question
1  
Calling a script with /bin/sh does not make it a bash script. –  adaptr Nov 2 '12 at 12:55

1 Answer 1

#!/bin/bash
read fred
echo $fred
share|improve this answer
    
I want to read multiple lines ! –  Stewie Nov 1 '12 at 20:46
1  
You should probably have said so, then. Do you want to read them to one variable, or many? More precision in the question will get you more functionality in the answers! –  MadHatter Nov 1 '12 at 21:11
    
@Stewie while read line ; do echo $line ; done –  ott-- Nov 2 '12 at 13:10
    
@MadHatter I had written that "What I eventually require is to read from the stdin written to by the postfix pipe" which would explain that the data will span multiple lines, but I guess it wasn't enough and I'll take care next time :) Anyway initializing as bin/bash instead of bin/sh solved it thanks –  Stewie Nov 2 '12 at 13:40

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.