redirecting serial inputs to a file?

i have an external device sending serial messages i want to connect this device to a serial port in my sun blade box and record those messages to a file, how can i read the serial port and write it to file?
Thanks

I dont know if the following code will work, but since all devices are essentially files, maybe you could do this:

while read message; do
echo $message > /path/to/file_you_want
done < /dev/path_to_serial_device

Not a whole lot of info here. Bear in mind that fibre channel and ethernet are serial too. We are moving towards a all-serial world. I guess we are talking about tty devices which are often labeled something like "Serial A" and "Serial B". If so, there could be some problems. Both the port and the device need to be configured to the same settings. To get started you will need to stuff like baud rate, character width, number of stop bits, and type of parity. You can depend on 1 stop bit being enough but everything else can vary. This is often expressed as something like "9600 8-1-none". You also need to know what kind of flow control the device supports and how fast it might send messages. And you need to know what format the messages are in. Are they binary data? Or are they 80 character lines of ascii data that could be typed at a keyboard?

thanks all for your answer, i'll try it tomorrow.\
You're right Perderabo, i was talking about an RS232 connection. All the parameters you mention are configurables on the external device and i have all the infor to change it, right now it is (i think) "32000-8-n-1" and messages are 80 characters by line, but i don't know how to configure the serial port on the box. wich command should i use?

You use the stty program to configure a port. The stty program operates on whatever tty is attached to fd 0. This enables stuff like:
stty -a < /dev/ttya > /some/data/file 2>&1
However, at close() time, the tty driver checks to see if any process still has the device file open. If not, the driver resets the port characteristics back to default. So the sequence:
stty -a < /dev/ttya
stty 38400 < /dev/ttya
stty -a < /dev/ttya
will show the port at 9600 before and after the stty command in the middle. This leads a lot of people to conclude that the middle stty command did not work. To fix this, open the tty and connect it to an unused fd early in the script. Like this:
exec 4</dev/ttya
this will keep the driver's close() routine from reseting the port.