use Device::SerialPort; use Data::Dumper qw(Dumper); my $port = Device::SerialPort->new("/dev/ttyUSB3"); $port->baudrate(115200); # Configure this to match your device $port->databits(8); $port->parity("none"); $port->stopbits(1); $port->lookclear; for($i=1;$i<=100;$i++){ $port->write("\n^^^^^^^^^^^ rebooted $i times ++++++++^^^^^^^^^^^ \n"); $port->write("cd /tmp \n"); $port->write("cp /mnt/usb/9798E1C89698/Disc-1/image.img . \n"); }