[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[MacPerl-AnyPerl] using Net::Telnet



Folks,

I'm looking to run a backup script via telnet. I want to connect to 
the server (login with username and password), run 'mysqldump' from 
the shell, which connects to the DB (needs username and password), 
and exit. Here is the code block and some results (the $host,etc. 
assignments and 'use Net::Telnet' statements are defined prior to 
this block):

# # # session details
my $file   = 'access_out';
my $t = new Net::Telnet(
                         Host      => $host,
                         Input_log => $file,
                         Timeout   => 10,
                         );
$t->login($user,$passwd);
$t->input_log;

# get structure only [line 21]
my $rc = $t->cmd('/export/home/src/mysql/bin/mysqldump -uwebdb -p -d 
journals > mysqldump_schema.out');
my ($prematch,$match) = $t->waitfor('/Enter password:.*$/');
$t->print($dbpasswd);

$t->close;
# # # end session
__END__

# Results:
# STDOUT: #command timed-out at Applications:Desktop 
Folder:mysqldump_run.pl line 22
# LOG:
# % /export/home/src/mysql/bin/mysqldump -uwebdb -p -d journals > 
mysqldump_schema.out
# Enter password:

Changing the timeout length, etc. has no impact.

I ran some of the sample code from the Net::Telnet POD successfully 
(simple shell commands like 'ls' and 'who'.) I didn't see anything 
helpful in the POD or a search of Deja.Com's archives.

Suggestions? This is probably not the best method for solving my 
problem. I'm  open to other techniques. The 'mysqldump' command 
requires a response so a shell script is out. Is there some other 
possiblity using Perl?

Paul
----

==== Want to unsubscribe from this list?
==== Send mail with body "unsubscribe" to macperl-anyperl-request@macperl.org