If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Perl and the DBI > Net::ssh:expect and DBI

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-20-07, 01:46
pimp1911 pimp1911 is offline
Registered User
 
Join Date: Aug 2007
Posts: 4
Net::ssh:expect and DBI

I am a newbie to perl so please forgive. My question. Can Net::ssh:expect be used to read from a local database(using DBI)for password and userid information. For exmaple Mysql. I am trying to set something up where the userid and password are taken from a local mysql database based on if they are active(ie flag) customer. If so. Read from the local database that contains login infromation and then establish a remote connection to another server.
Reply With Quote
  #2 (permalink)  
Old 08-30-07, 14:18
pimp1911 pimp1911 is offline
Registered User
 
Join Date: Aug 2007
Posts: 4
Well after some painful research and trial and error. I have my code reading from a mysql database instead of hard coding the password(s) in the code. I can connect just fine and run commands. Now the problem I am facing is trying to start a SFTP command on the remote machine and ftping a file back to my localhost. Can this be done within Net::ssh:expect or do I have to use something outside of Net:ssh:expect like Net:scp or Net:sftp.
Reply With Quote
  #3 (permalink)  
Old 08-30-07, 23:45
pimp1911 pimp1911 is offline
Registered User
 
Join Date: Aug 2007
Posts: 4
I am connected already on the remote server. Then I kick off these commands.
Will this work
my $sftp = $ssh->exec("sftp username\@remote host");
my $pass = $ssh->exec("password");

My debug log tells me at this point that I have a sftp prompt. But the sftp prompt wont except my next command.
my $mput = $ssh->send("mput *.tar")
Reply With Quote
  #4 (permalink)  
Old 08-31-07, 07:19
pimp1911 pimp1911 is offline
Registered User
 
Join Date: Aug 2007
Posts: 4
Okay I did this and got it working. Thanks for listening everyone. I guess talking to yourself does work. LOL.


my $sftp = $ssh->exec("sftp username\@remote host");
my $pass = $ssh->exec("password");

$ssh->waitfor('sftp>', 20); # Wait 20 seconds to get 'sftp>' prompt.

my $mput = $ssh->send("mput *.tar");
Reply With Quote
  #5 (permalink)  
Old 09-05-07, 02:45
sco08y sco08y is offline
Registered User
 
Join Date: Oct 2002
Location: Baghdad, Iraq
Posts: 697
I'm sorry, I usually don't hit the Perl threads and must have missed yours.

You know there's an option to encrypt a DBI session with SSL? Check the DBD::mysql docs for "mysql_ssl". Your mysql installation needs to be compiled with ssl support, of course.

But you didn't waste your time learning how to use ssh, it's pretty handy for a lot of things.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On