Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: easy way to read from stdin ?



On Jun 23,  6:42pm, Sweth Chandramouli wrote:
} Subject: Re: Re: easy way to read from stdin ?
}
} > What is it that you are doing to cause it to read from a file?  That is,
} > when it's not a cgi, how do you run it?
} 	i put a "< filename" after the while read loop, so that it would
} read input from the file "filename".  basically, i'm trying to create a
} mailto form here--it should take the values from the form in question,
} [...]
} but when i run it as a form, it acts as though it is getting no input.

Is the form using METHOD=post to send data to the server?  Otherwise there
isn't any standard input.  The enviroment variable CONTENT_LENGTH should
tell how many bytes you can expect to read.

Try doing

	local input
	read -u0k $CONTENT_LENGTH input

This should stuff the entire stdin (up to $CONTENT_LENGTH bytes) into
the variable "input".  The input may be coming to you with "\r\n" line
endings, in which case I'm not sure how a plain "read" behaves. 

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com



Messages sorted by: Reverse Date, Date, Thread, Author