Reputation: 183
#!/usr/local/bin/perl
use strict;
use warnings;
system("cd $PATH
/usr/bin/sftp mysite.com <<!EOF
put sample.txt
bye
!EPF");
When i complile tha application, it asking the pasword, how to pass the user/password in the code itself,
what i want is, my script should not ask the password. i want to set the user/password in the code itself. user command not working in sftp How to make it.
Upvotes: 3
Views: 12889
Reputation: 1542
With such a vague question its hard to give more of an answer…
Have you tried the Net::SFTP module?
EDIT:
Based on the edit to the question - try using Net::SFTP::Foreign
use Net::SFTP::Foreign;
use warnings;
use strict;
my $host = "xxx.xxx.xxx.xxx";
my $sftp = Net::SFTP::Foreign->new($host, user => 'user', password => 'pass');
$sftp->error and die "Something bad happened: " . $sftp->error;
$sftp->put("sample.txt", "/home/test/test") or die "put failed: " . $sftp->error;
You should get a more meaningful error message and you can take it from there.
Upvotes: 6
Reputation: 6524
You can try other modules, e.g Net::SFTP::Foreign or the SFTP functionality of Net::SSH2.
Upvotes: 1