An expect
script should do.
#!/usr/bin/expect -f
spawn telnet 192.168.0.45 23
expect login
send "root\n"
send "cd /flash\n"
send "nc 192.168.0.10 10001 >lasertest\n"
send "exit\n"
expect eof
If the login prompt doesn't contain "login", change the "expect" command suitably.