linux - how to run command on telnet command prompt in perl script -
i executing telnet command in perl script below.
$telnetoutput = `telnet localhost 4505`; print "\n telnet command output: $telnetoutput \n"; $clients = `clients`; print"\n $clients\n"; $clientnumber_or_anyotherkey = `1`; print "\n $clientnumber_or_anyotherkey \n"; $pollers = `pollers`; print "\n $pollers\n";`
but after running $telnetoutput = `telnet localhost 4505
`; command, know open telnet command prompt other commands still executing in same old command prmopt it's saying clients
or 1
or pollers
not recognized internal or external commands.
can 1 me out pls? in advanch
communicating external processes telnet more complicated might imagine, have correctly handle buffering, waiting input, , on.
the canonical way approach use expect ( https://metacpan.org/module/rgiersig/expect-1.21/expect.pod ) if need full interaction.
if don't need interaction remote command runner ssh
or rsh
(which can call perl of course) sufficient.
Comments
Post a Comment