Print to text file?

I need to get data sent from my arduino into a text file. Like Serial.print(), except the output would be in a text file instead of the serial monitor. Anybody know how I might go about doing that?

Use the piece of vb script posted in this thread:

Anyway to use that while also keeping the arduino serial monitor open? I'm sending commands via the serial monitor and wanting to log the results in a text file.

Assuming windows, and your com port is defaulting to the Arduino's settings, your should be able to enter at the dos prompt

copy com5: somefile.txt

thats with com5, and you'll have to end your output with a ^Z (ascii 26)

Can someone help me do this on linux (ubuntu 8.10) I want the last line to go to a file so I can write a simple script in mIRC to update twitter/facebook status. Lots of people are doing this but obviously it could be alot simpler if someone just knew how to get that last line to a file.

To florinc,

I tried the VB script you posted. But I only got one line data, there supposed to be more data. why?

Besides, I tried to use the serial port communication programming in C/C++. But have problems to communication with arduino

My aim is to grab the data which constantly displayed on monitor , and save them.

Are you sure that you send more data from arduino (try the serial monitor in arduino IDE first, to check that)? Secondly, that VB script, once started, never ends by itself. A second instance may report an error, due to conflicting access to the specified COM port. To force-end the script, terminate it in Task Manager (process is called "wscript").

i succesfully grab the data from serial port using win32 API programming such as CreateFile(), ReadFile()…etc…