Results 1 to 5 of 5
  1. #1
    Join Date
    Aug 2007
    Posts
    4

    Unanswered: 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.

  2. #2
    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.

  3. #3
    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")

  4. #4
    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");

  5. #5
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •