Re: How to execute commands one by one - WeOnlyDo Discussion board

Re: How to execute commands one by one (General questions)

by lax4u, Tuesday, July 03, 2007, 18:15 (6353 days ago) @ wodDamir

Thank you very much guys. It wotked, im able to transfer file finally. The only thing, Execute command doesnt work for me, dont know why. So i have keep reading line by line untill i find Token and then Send the command. My working code look like this.. any improvement u suggest

telnet1.Connect(IPADDRESS, 23, WODTELNETDLXCOMLIB.ProtocolsEnum.Telnet);
screen = telnet1.WaitFor( Press any key to continue , timeout);
telnet1.DataReady = 0;
telnet1.Send(LF);
if (!WhileTokenNotFound( Enter a function code ))
{
telnet1.Send( DTL +LF);
if (!WhileTokenNotFound( : ))
{
telnet1.Send( sys );
if (!WhileTokenNotFound( $ ))
{
telnet1.Send( cd /ppp/client/test );
if (!WhileTokenNotFound( $ ))
{
telnet1.Send( rz + LF);
telnet1.SendFile(WODTELNETDLXCOMLIB.TransferProtocolsEnum.ZMODEM, C:\myTestFile.txt , false);
}
}
}
}

private bool WhileTokenNotFound(string Token)
{
screen = string.Empty;
bool notFound = true;
while (notFound)
{
if (screen.IndexOf(Token) == -1)
{
screen = telnet1.ReceiveLine();
telnet1.Send(LF);
AddToList(screen);
}
else
{
notFound = false;
}
}
return notFound;
}


Complete thread: