Can't trigger arduino via serial after reboot

I'm running a bash script on Ubuntu 10.04 to send a simple on/off message via serial to an Arduino Diecimila.

Here's the bash script (called with an argument of either 1 or 0 to turn on and off):

#!/bin/bash

#configure the serial connection to talk to the arduino
stty -F /dev/ttyUSB0 cs8 9600 ignbrk -brkint -icrnl -imaxbel -opost -onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke noflsh -ixon -crtscts

echo -n $1 > /dev/ttyUSB0
exit 0

and here's the sketch:

int incomingByte = 0;

void setup() {
        Serial.begin(9600);
        pinMode(13, OUTPUT);
}

void loop() {

        if (Serial.available() > 0) {
                incomingByte = Serial.read();
                if (incomingByte == 49 )
                {
                  digitalWrite(13, HIGH);
                }
                else
                {
                  digitalWrite(13, LOW);
                }
        }
}

The problem is that after rebooting the PC, the arduino doesn't respond to the serial command. The serial LED flashes briefly on the board, but the LED is not lit. If I run the Arduino IDE programme and start the serial monitor, then the bash script works, even after exiting the IDE. I also have the same problem with a python script. Is there a command needed to open the connection?

Can anyone help with this?

thanks

James

Ah ok, after some more searching it seems that sending the serial command causes the arduino to reset, therefore it misses the command. A workaround for me is to disable the reset with a 100 ohm resistor between the reset pin and 5V.

The Arduino resets when the IDE's serial monitor connects to the serial port. This is triggered by one of the control signals - DTR I think, but don't quote me. If you could connect without triggering the relevant control signal, it would avoid the reset. (Or, you can inhibit the reset in hardware on the Arduino board.)