I am utilising the Net::Telnet module in order to access a remote terminal to make an SQL query into a database.
As suggested within the documentation, I am utilising the cmd() command to interact with terminal. This command is recommended to read data into an array from the terminal (see code below).
The debug generated is as follows:# # SQL Query to execute # $cmd = "select * from table A"; # # Wait for prompt - ">>" at terminal # $t->prompt('/\>\>\s*$/'); # # Send SQL Query to terminal # $t->cmd($cmd); # # Debug # print "cmd 1 = $cmd<p><p>" if $debug; # # Execute SQL command # $cmd = "go"; # # Wait for prompt - "(1)>>" # $t->prompt('/\(\1\)\>\>\s*$/'); # # Read in data from terminal to array # @lines = $t->cmd($cmd); # # Debug # print "prompt_string = $prompt_string<p>" if $debug; print "lines = $t->cmd($cmd)<p>" if $debug; print "lines array = @lines<p>" if $debug; print "cmd 2 = $cmd<p>" if $debug;
The code appears to compile correctly, however, when attempting to debug out the @lines array, I get a blank. I have also attempted to convert @lines to a scalar value to check how many lines it contains and this yields a 0.cmd 1 = select * from table A lines = Net::Telnet=<edited>->cmd(go) lines array = cmd 2 = go NoLines = 0
It appears that for some reason, the @lines array has not been populated. Could anyone suggest a reason as to how to overcome this problem?
(I have manually queried the database with the SQL query which results in a 2 column/1 row table)
Thanks in advance...
update (broquaint): added formatting
In reply to CMD Command by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |