Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

SCP help

by PyrexKidd (Monk)
on May 03, 2010 at 03:38 UTC ( #838026=perlquestion: print w/ replies, xml ) Need Help??
PyrexKidd has asked for the wisdom of the Perl Monks concerning the following question:

I am trying to copy a file securely to my server. using the following line

system('scp -P 223 /home/my/local/file/whatever.txt root:root_password +\');
when I run it I get the following error:
ssh: Could not resolve hostname root: Name or service not known

what is going on?

Comment on SCP help
Select or Download Code
Replies are listed 'Best First'.
Re: SCP help
by ikegami (Pope) on May 03, 2010 at 05:08 UTC
    You would have gotten the same result from the prompt. Your problem has nothing to do with Perl.
    means file on machine root. The path should be
    You could feed the password to its STDIN (probably), but it would be better if you used public key authentication (so you don't need to specify a password at all).
      You could feed the password to its STDIN (probably)
      Not really, ssh opens /dev/tty and reads the password from there.
Re: SCP help
by codeacrobat (Chaplain) on May 03, 2010 at 06:23 UTC
    Hello, there are perl modules for this kind of job, e.g. Net::SFTP::Foreign, Net::SSH2. Maybe these modules help you to integrate ssh better into your perl scripts.

      ... and Net::OpenSSH that being on an Unix OS, maybe Linux, it's probably the easiest one to install and use for SCP file copy.
      use Net::OpenSSH; my $ssh = Net::OpenSSH->new('', passwd => $passwd, port => 223); $ssh->scp_put("/home/my/local/file/whatever.txt", "/my/remote/path_name");
Re: SCP help
by nagalenoj (Friar) on May 03, 2010 at 05:59 UTC

    If it's not an interactive kind of script, you could try copying the public key to the authorized keys file. ssh without password linux

    But, here the problem is in your syntax.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://838026]
Approved by ww
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (4)
As of 2015-10-07 21:22 GMT
Find Nodes?
    Voting Booth?

    Does Humor Belong in Programming?

    Results (200 votes), past polls